Hello there, I am learning python as a hobby in my spare time. I enjoy doing
"project euler", not that I am any good at maths, but it gives me problems
to solve in python!
Please Note: I do not expect (or want) you to give me the solution, if you
could just point me in the right direction - that would be great.

The problem is as follows:

*A unit fraction contains 1 in the numerator. The decimal representation of
the unit fractions with denominators 2 to 10 are given:*

 [image: ^(]*1/2*[image: )][image: _(][image: )]*= **0.5*  [image:
^(]*1/3*[image:
)][image: _(][image: )]*= **0.(3)*  [image: ^(]*1/4*[image: )][image:
_(][image:
)]*= **0.25*  [image: ^(]*1/5*[image: )][image: _(][image: )]*= **0.2*  [image:
^(]*1/6*[image: )][image: _(][image: )]*= **0.1(6)*  [image: ^(]*1/7*[image:
)][image: _(][image: )]*= **0.(142857)*  [image: ^(]*1/8*[image: )][image:
_(][image: )]*= **0.125*  [image: ^(]*1/9*[image: )][image: _(][image: )]*=
**0.(1)*  [image: ^(]*1/10*[image: )][image: _(][image: )]*= **0.1*

*Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can
be seen that 1/7 has a 6-digit recurring cycle.*[image: ^(][image: )][image:
_(][image: )]

*Find the value of **d [image: <] 1000 for which 1/d contains the longest
recurring cycle in its decimal fraction part.*


I've written a "division" function that gives more decimal places than the
one already in python. What my poor old brain can't work out is how to find
a "recurring cycle" which isn't disastrously complicated (as the cycle
doesn't always include the first decimal places and the length is unknown).

Any ideas would be greatly appreciated.

Thanks in advance

Colin
[image: ^(][image: )][image: _(][image: )]
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to