diff options
Diffstat (limited to 'day1/exercise/aliquot.py')
-rw-r--r-- | day1/exercise/aliquot.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/day1/exercise/aliquot.py b/day1/exercise/aliquot.py index 96ea916..25518f0 100644 --- a/day1/exercise/aliquot.py +++ b/day1/exercise/aliquot.py @@ -1,18 +1,13 @@ -def is_perfect_square(n): - i = 1 - while i * i < n: - i += 1 - return i * i == n, i def aliquot(n): sum = 1 i = 2 - is_ps, root = is_perfect_square(n) - while i < root: + while i * i < n: if n % i == 0: sum += i + (n / i) i += 1 + if n % i == 0: sum += i return sum n = int(raw_input('Enter a number? ')) |