[Tutor] Problem Euler 26
Martin Walsh
mwalsh at groktech.org
Mon Jun 30 00:47:31 CEST 2008
kinuthiA muchanE wrote:
>
> (28, '035714286')
> (38, '026315789')
> (81, '012345679')
>
> For 28, the digit, in the fractional part, after 8 is 5, so 5 is
> repeated and as for, 81 the next digit after 7 is 0, so again 0 occurs
> twice. But for 38, the next digit after 9 is 4, and because it has NOT
> occurred before, I assume 38 is the correct answer... and I am wrong!
>
Ah, sorry -- I didn't parse this properly the first time through. You
should also be aware of the limitations of representing a decimal
fractions as a float. I'll defer to the docs, instead of trying (and
failing) to explain this myself: http://docs.python.org/tut/node16.html
Also, have a look in the standard library, there was a module added in
2.4 which will provide additional assistance.
HTH,
Marty
More information about the Tutor
mailing list