Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: latin-1 -*-
- import sys
- import math
- def feliz(x):
- """ analiza si es un numero feliz """
- memoria=[]
- r=0
- while x!='1' and not (x in memoria):
- memoria.append(x) # x en la memoria por si se repite
- for n in x:
- r+=int (n)**2
- x=str(r) #crea el nuevo numero de entrada
- r=0
- return x
- n = int(input()) #n numeros a probar
- for i in range(n):
- x = input()
- print (str(x)+" "+ (':)' if feliz(x)=='1' else ':(' ) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement