Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Prime(p):
- return 2 in [p, 2**p%p]
- def Mersenne_prime(p):
- if Prime(p):
- p = ((2**p) - 1)
- if Prime(p):
- return True
- return False
- def Euclid_Theory(p):
- if Mersenne_prime(p):
- perfect_num = ((2**(p-1)) * ((2**p) - 1))
- return perfect_num
- return 0 #if Mersenne is False then return 0 else return perfect_num
- def Solve(area):
- odd = 2
- perfect_num = Euclid_Theory(odd)
- odd = 3
- while True:
- if perfect_num > area:
- break
- else:
- if perfect_num != 0:
- print(perfect_num)
- perfect_num = Euclid_Theory(odd)
- odd += 2
- if __name__ == "__main__":
- t = int(input())
- for i in range(1, t+1):
- area = int(input())
- if area >= 6:
- Solve(area)
- if i != t:
- print()
Add Comment
Please, Sign In to add comment