Skip to content

Commit

Permalink
problem 14
Browse files Browse the repository at this point in the history
  • Loading branch information
birkoffe committed Dec 31, 2016
1 parent b2a4792 commit dbf7e4a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions 014/anwser.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
837799
25 changes: 25 additions & 0 deletions 014/solve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/python

longestN = 0
longest = 0
limit = 1000001
hist = [0 for x in xrange(limit)]

for x in xrange(2, limit):
n = x
i = 0
while n != 1:
if n < limit and hist[n] > 0:
i += hist[n]
break
if n%2 == 0:
n /= 2
else:
n = 3*n+1
i += 1
hist[x] = i
if i > longest:
longest = i
longestN = x

print longestN

0 comments on commit dbf7e4a

Please sign in to comment.