Commit 04b49530 authored by Taddeus Kroes's avatar Taddeus Kroes

Finished 26

parent 13a15978
#!/usr/bin/env python #!/usr/bin/env python
for i in range(2, 11): from decimal import getcontext, Decimal
r = str(round(1. / i, 1000))[2:-1]
for l in range(len(r) / 2, 0, -1): def findrec(d):
pass getcontext().prec = d * 3
dec = str(Decimal(1) / d)[2:]
print i, r for l in xrange(d - 1, 0, -1):
for offset in xrange(d):
pivot = len(dec) - offset - l
left = dec[pivot - l:pivot]
right = dec[pivot:pivot + l]
if left == right:
if len(left) == 1 or len(set(left)) > 2:
return dec[pivot - l:pivot]
if __name__ == '__main__':
longest = 0
ld = None
for d in xrange(2, 1000):
rec = findrec(d)
if rec and len(rec) > longest:
longest, ld = len(rec), d
print '%d (%d)' % (d, longest), rec
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment