-
Notifications
You must be signed in to change notification settings - Fork 0
/
euler_01.py
40 lines (24 loc) · 910 Bytes
/
euler_01.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#################### 1 ####################
def sum_of_multiples(target_number,multiples=[]):
sum = 0
for i in range(target_number):
for number in multiples:
if i % number == 0:
sum += i
break
print(f"Result:{sum}")
sum_of_multiples(1000,[3,5])
#################### 2 ####################
def sum_of_multiples(target_number,multiples=[]):
summation = set()
for number in multiples:
static_number = number
while target_number>number:
summation.add(number)
number += static_number
print(f"Result:{sum(summation)}")
sum_of_multiples(1000,[3,5])
#################### 3 ####################
def sum_of_multiples(target_number):
print(f"Result:{sum(i for i in range(target_number) if i % 3 == 0 or i % 5 == 0)}")
sum_of_multiples(1000)