Skip to content

Instantly share code, notes, and snippets.

@shieldsd
Created March 30, 2012 14:11
Show Gist options
  • Save shieldsd/2251786 to your computer and use it in GitHub Desktop.
Save shieldsd/2251786 to your computer and use it in GitHub Desktop.
Project Euler #26
def seqlen(n):
rem = []
x = 1
while 1:
x = (10 * x) % n
if x == 1:
rem.append(x)
break
elif x == 0:
break
elif x not in rem:
rem.append(x)
else:
break
return len(rem)
print max((seqlen(x), x) for x in range(1, 1000))[1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment