Skip to content

Instantly share code, notes, and snippets.

@sneilan
Created April 19, 2012 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sneilan/2424481 to your computer and use it in GitHub Desktop.
Save sneilan/2424481 to your computer and use it in GitHub Desktop.
a = 1 # 1000^0
i = 0 # represents the largest power of 1000 we found
# find the largest power of 1000 that fits into n
while a <= n:
#print a,n,i
if a*1000 <= n:
a *= 1000
i += 1
else:
if a > n:
a /= 1000
i -= 1
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment