[Tutor] help finding recurring cycle

col speed ajarncolin at gmail.com
Wed Dec 24 06:03:53 CET 2008


Thank you, thank you thank you! I'm now well on my way to solving my 35th
problem!! The wiki is fantastic, I thought "of course - I should have known
that!" It's easy when you know how.
Thanks again, especially for the prompt replies

2008/12/24 bob gailer <bgailer at gmail.com>

> Kent Johnson wrote:
>
>> On Tue, Dec 23, 2008 at 8:20 PM, col speed <ajarncolin at gmail.com> wrote:
>>
>>
>>
>>> 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).
>>>
>>>
>>
>> I would look for repetition in the remainder (the dividend) at each
>> step. Perhaps keep a dict which maps dividend to position, then when
>> you get a repeat you can figure out how long the cycle is.
>>
>> Kent
>>
>>
>
> Check out http://en.wikipedia.org/wiki/Repeating_decimal.
>
> Section 5 How a repeating or terminating decimal expansion is found
> illustrates the above.
>
> --
> Bob Gailer
> Chapel Hill NC 919-636-4239
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20081224/80e750d1/attachment.htm>


More information about the Tutor mailing list