-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproblem_005.py
37 lines (25 loc) · 848 Bytes
/
problem_005.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
# https://projecteuler.net/problem=5
import math
import unittest
from itertools import product
def smallest_multiple(n):
current_number = 1
current_number_division_count = 0
while True:
for m in range(1, n+1):
if current_number % m == 0:
current_number_division_count += 1
if current_number_division_count == n:
return current_number
print(current_number)
print(current_number_division_count)
# reset for new iteration
current_number += 1
current_number_division_count = 0
class TestSmallestMultiple(unittest.TestCase):
def test_1_1(self):
self.assertEqual(smallest_multiple(10), 2520)
def test_1_2(self):
self.assertEqual(smallest_multiple(20), 232792560)
if __name__ == '__main__':
unittest.main()