[algogeeks] Re: recurring number

2010-07-02 Thread Dave
Okay. Here is some code to determine the number of digits in the period of repetition of the decimal expansion of 1/n, where n > 0: int period(int n); { int i=1,j=0; while( n % 2 == 0 ) n /= 2; while( n % 5 == 0 ) n /= 5; do { i = (10 * i) % n; +

Re: [algogeeks] Re: recurring number

2010-07-02 Thread jalaj jaiswal
hmm. :-o On Fri, Jul 2, 2010 at 5:57 PM, Dave wrote: > Yes. With a period of 16: > 1/17 = 0.0588235294117647 0588235294117647 0588235294117647 ... > > Dave > > On Jul 2, 5:22 am, jalaj jaiswal wrote: > > @dave > > is 1/17 recurring...?? > > @abhirup > > now convert float to string ..only pa

[algogeeks] Re: recurring number

2010-07-02 Thread Dave
Yes. With a period of 16: 1/17 = 0.0588235294117647 0588235294117647 0588235294117647 ... Dave On Jul 2, 5:22 am, jalaj jaiswal wrote: > @dave > is 1/17 recurring...?? > @abhirup > now convert float to string ..only part after decimal > > now let the string be .346346346. > take an auxilarry

Re: [algogeeks] Re: recurring number

2010-07-02 Thread rizwan hudda
Yes. What if the recurring number is more than 20 digits? On Fri, Jul 2, 2010 at 9:33 AM, Dave wrote: > Does it work for 1/17, 2/17, 3/17, etc.? > > Dave > > On Jul 1, 5:23 pm, jalaj jaiswal wrote: > > we are given with Numerator and Denominator. After division we might get > a > > recurring d

[algogeeks] Re: recurring number

2010-07-01 Thread Dave
Does it work for 1/17, 2/17, 3/17, etc.? Dave On Jul 1, 5:23 pm, jalaj jaiswal wrote: > we are given with  Numerator and Denominator. After division we might get a > recurring decimal points float as the answer. > For example 23.34563456 ... > return 3456 i.e the recurring part > > i did it by c