Skip to content

Instantly share code, notes, and snippets.

@gnuget
Created August 19, 2009 23:36
Show Gist options
  • Save gnuget/170724 to your computer and use it in GitHub Desktop.
Save gnuget/170724 to your computer and use it in GitHub Desktop.
def recu(x):
li = []
lista = []
li.append('numero')
while x > 1:
if x % 2:
x = x * 3 + 1
lista.append(x)
else:
x = x / 2
lista.append(x)
return len(lista)+1
# este es para hace de 1... n y llama recu pinta los num
def cosa(inicio,fin):
succesions = [] #guardamos los totales de las succesiones aquí
for i in range(inicio,fin+1):
succesions.append(recu(i)) #agregamos el numero de succeions de i
m = max(succesions) #sacamos el numero de suceciones mas alto de la lista de succesiones
return m #regresamos ese numero
inicio = 10
fin = 22
numero = cosa(inicio,fin)
print inicio, fin, numero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment