[PYTHON] Learn math and English through programming (Part 1)

problem

https://projecteuler.net/problem=1

English words to use

https://progeigo.org/learning/essential-words-600-plus/ Words starting with A

program


#!/usr/bin/python3
# -*- coding: utf-8 -*-

# author : my page
# account : my page
# my favorite audio : anime song

import sys

#Numbers that allow division
allow_numer_list = [3,5]

if len(sys.argv) != 2 :
    #Enter one argument to accept the use of this application.
    print('To accept the usage of this application, input one argumet.')
    sys.exit(1)

try :
    #Numbers to apply
    apply_number = int(sys.argv[1])

except :
    #This argument is not an available attribute
    print('This argument is not available attribute.')
    sys.exit(1)

#Numbers to get
access_number = 0
#Array
array = range(1, apply_number)
for num in array :
    #Alternative numbers?
    for alternative_num in allow_numer_list :
        #Algorithm that does not avoid?
        # not avoid algorithm
        if num % alternative_num == 0:
            access_number += num
            break

print(access_number)

Execution result


# python3 test.py 1000
233168

Conclusion

I will study English more.

Recommended Posts

Learn math and English through programming (Part 1)
Learn math and English by programming (Part 2)
Learn math and English through programming (Part 1)
Learn Python and AI related English words. .. ..
[Python] Learn about asynchronous programming and event loops
GUI programming with kivy ~ Part 3 Video and seek bar ~
Learn "English grammar" instead of Python and AI related English words. .. ..
Machine learning to learn with Nogizaka46 and Keyakizaka46 Part 1 Introduction