-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEuler_project_5.py
45 lines (36 loc) · 1.07 KB
/
Euler_project_5.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
41
42
43
44
45
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 9 17:36:08 2019
@author: aurelio
"""
'''
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
'''
maxNumber = 10
divisivel = list()
for i in range(2,maxNumber+1):
divisivel.append(list())
count = 0
number = i
for j in range(2,maxNumber+1):
while(number > 1):
if number % j == 0:
number = number/j
count+=1
else:
break
divisivel[i-2].append(count)
count = 0
finalCombination = list()
biggerExponent = 0
for i in range(len(divisivel[0])):
for j in range(len(divisivel[:][0])):
if divisivel[j][i] > biggerExponent:
biggerExponent = divisivel[j][i]
finalCombination.append(biggerExponent)
biggerExponent = 0
acumulator = 1
for i in range(len(finalCombination)):
acumulator = acumulator*(i+2)**finalCombination[i]
print(acumulator)