Re: [Tutor] Problem Euler 26
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 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Problem Euler 26
kinuthiA muchanE wrote: > Hi, Hi Kinuthia, > I am trying to solve Problem Number 26 > (http://projecteuler.net/index.php?section=problems&id=26) on project > Euler but apparently the answer I am submitting is wrong. > I am a big fan of Project Euler also. Fun stuff. > I suspect I have completely misunderstood the question. You're probably right, but it's not clear from your description (to me anyway), what your understanding of the question is. > > Any ideas? > Thanks! Perhaps it would be helpful to look at the next few values of d, as defined by the question (note: the parens enclose the repeating pattern): """ 1.0/11 = 0.(09) 1.0/12 = 0.08(3) 1.0/13 = 0.(076923) 1.0/14 = 0.0(714285) 1.0/15 = 0.0(6) 1.0/16 = 0.0625 1.0/17 = 0.(0588235294117647) """ No spoilers there, hopefully :) Have fun! Marty ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor