commit e14ff0a108befba563bda3f94d8a863ac8d1fc8a parent d68b4fba9b6c63b54d9ed162feb632f3e011a8ef Author: therealFIGBERT <figbertwelner@gmail.com> Date: Mon, 20 Jan 2020 14:41:52 -0800 Add solution to problem #1 Diffstat:
A | problem001.py | | | 22 | ++++++++++++++++++++++ |
1 file changed, 22 insertions(+), 0 deletions(-)
diff --git a/problem001.py b/problem001.py @@ -0,0 +1,22 @@ +# problemName = "Multiples of 3 and 5" +# problemNum = 1 +# solutionBy = "FIGBERT" +# language = "Python" +# dateCompleted = "20/01/2020" + +def multOfThreeOrFive(num): + if num % 3 is 0 or num % 5 is 0: + return True + return False + +def sumOfMultiplesOfThreeOrFive(num): + lstOfMults = [] + numStep = num - 1 + while numStep > 0: + if multOfThreeOrFive(numStep): + lstOfMults.append(numStep) + numStep -= 1 + return sum(lstOfMults) + +answer = sumOfMultiplesOfThreeOrFive(1000) +print("The sum of all the multiples of 3 or 5 below 1000 is %s" % answer)