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 <bgai...@gmail.com> > Kent Johnson wrote: > >> On Tue, Dec 23, 2008 at 8:20 PM, col speed <ajarnco...@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 > >
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor