Skip to content

Instantly share code, notes, and snippets.

@de1o
Created May 17, 2012 04:00
Show Gist options
  • Save de1o/2716186 to your computer and use it in GitHub Desktop.
Save de1o/2716186 to your computer and use it in GitHub Desktop.
colazCalculatingTime
# colazCalculatingTime.py
import time
colazStopNumList = []
def colaz(n, cnt):
if n == 1:
colazStopNumList.append(cnt)
return 0
if n % 2 == 0:
n = n/2
else:
n = 3*n + 1
colaz(n, cnt+1)
startTime = time.clock()
for i in range(65536):
colaz(i+1, 0)
print (time.clock() - startTime)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment