[Tutor] help finding recurring cycle

Kent Johnson kent37 at tds.net
Wed Dec 24 03:38:53 CET 2008

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.


More information about the Tutor mailing list