Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/Arithmetic-Rational/Python/arithmetic-rational-1.py
Normal file
10
Task/Arithmetic-Rational/Python/arithmetic-rational-1.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
from fractions import Fraction
|
||||
|
||||
for candidate in range(2, 2**19):
|
||||
sum = Fraction(1, candidate)
|
||||
for factor in range(2, int(candidate**0.5)+1):
|
||||
if candidate % factor == 0:
|
||||
sum += Fraction(1, factor) + Fraction(1, candidate // factor)
|
||||
if sum.denominator == 1:
|
||||
print("Sum of recipr. factors of %d = %d exactly %s" %
|
||||
(candidate, int(sum), "perfect!" if sum == 1 else ""))
|
||||
Loading…
Add table
Add a link
Reference in a new issue