Created
April 19, 2012 21:57
-
-
Save sneilan/2424481 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
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