project-euler-100

[RADIOACTIVE] solutions to the first 100 challenges of project euler
git clone git://git.figbert.com/project-euler-100.git
Log | Files | Refs | README

problem001.py (632B)


      1 # problemName = "Multiples of 3 and 5"
      2 # problemNum = 1
      3 # solutionBy = "FIGBERT"
      4 # language = "Python"
      5 # dateCompleted = "20/01/2020"
      6 
      7 def mult_of_three_or_five(num):
      8     return num % 3 == 0 or num % 5 == 0
      9 
     10 def sum_of_multiples_of_three_or_five(num):
     11     list_of_multiples = []
     12     num_step = num - 1
     13     while num_step > 0:
     14         if mult_of_three_or_five(num_step):
     15             list_of_multiples.append(num_step)
     16         num_step -= 1
     17     return sum(list_of_multiples)
     18 
     19 if __name__ == "__main__":
     20     answer = sum_of_multiples_of_three_or_five(1000)
     21     print("The sum of all the multiples of 3 or 5 below 1000 is %s" % answer)