Created
August 19, 2009 23:36
-
-
Save gnuget/170724 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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