Created
October 23, 2013 11:27
-
-
Save david-batranu/7116897 to your computer and use it in GitHub Desktop.
This file contains 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
collatz = {1:1} | |
def Collatz(n): | |
global collatz | |
if not collatz.has_key(n): | |
if n%2 == 0: | |
collatz[n] = Collatz(n/2) + 1 | |
else: | |
collatz[n] = Collatz(3*n + 1) + 1 | |
return collatz[n] | |
for j in range(1000000,0,-1): | |
Collatz(j) | |
print collatz.keys()[collatz.values().index(max(collatz.values()))] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment