Initial release
This commit is contained in:
19
Les nombres heureux.py
Normal file
19
Les nombres heureux.py
Normal file
@@ -0,0 +1,19 @@
|
||||
mini = 8962
|
||||
maxi = 9189
|
||||
|
||||
def is_happy(n):
|
||||
table = list()
|
||||
while len(str(n))>1:
|
||||
n = str(sum([int(i)**2 for i in str(n)]))
|
||||
if n in table:
|
||||
break
|
||||
else:
|
||||
table.append(n)
|
||||
return n=="1"
|
||||
|
||||
solution = list()
|
||||
for i in range(mini, maxi+1):
|
||||
if is_happy(i):
|
||||
solution.append(i)
|
||||
|
||||
print(solution)
|
||||
Reference in New Issue
Block a user