Created
March 9, 2011 14:50
-
-
Save Motoma/862306 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
def BaseSeven(num): | |
powersOfSeven = 1; | |
res = 0; | |
while num / powersOfSeven > 6: powersOfSeven = powersOfSeven * 7 | |
while powersOfSeven != 1: | |
res = res * 10 + int(num / powersOfSeven) | |
num = num - int(num / powersOfSeven) * powersOfSeven | |
powersOfSeven = powersOfSeven / 7 | |
res = res * 10 + num | |
return res | |
def HasThreeZeros(num): | |
return str(num).find("000") != -1 | |
def FindWithoutZeros(power): | |
lastWithoutThreeZeros = power | |
failures = -1 | |
num = pow(2, power) | |
while failures <= lastWithoutThreeZeros: | |
if HasThreeZeros(BaseSeven(num)): | |
failures = failures + 1 | |
else: | |
failures = 0 | |
lastWithoutThreeZeros = power | |
print power | |
power = power + 1 | |
num = num * 2 | |
if (float(power) / 100) == int(power / 100): print "CheckPoint:", power | |
return lastWithoutThreeZeros | |
print FindWithoutZeros(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment