Skip to content

Commit

Permalink
Euler_Perfects.py
Browse files Browse the repository at this point in the history
Using Euler's algorithm about "Perfect Numbers" to calculate all numbers of "Perfect Numbers".
  • Loading branch information
linye1111 authored Jan 12, 2018
1 parent 216da7b commit eecd37a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Euler_Perfects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import time
start = time.time()
def isprime(num):
if num < 2:
return False
if num == 2:
return True
for i in range(2, int(num*0.5+1)):
if num%i == 0:
return False
return True
L = list()
for i in range(10000):
if isprime(i):
L.append(i)
print(L)

for i in L:
j = 2**i-1
if isprime(j):
print(time.time()-start)
print(2**(i-1)*(j))
i += 1

0 comments on commit eecd37a

Please sign in to comment.