Click to See Complete Forum and Search --> : Recurring Decimal
perito
May 11th, 2008, 02:28 PM
lets say we have
x = 1/7
x = 0.142857 142857 142857 142857
the recurring cycle in this decimal is 142857
is there anyway to find this, or at least the length of it?
for example, if x = 1/7 >> y = 142857
I don't want a code, I want a method...
Thanks
NickThissen
May 11th, 2008, 03:28 PM
Have a look on wikipedia:
http://en.wikipedia.org/wiki/Recurring_decimal
Quite interesting tbh, although I never thought about it before.
From the wikipedia site:
From this kind of argument, we can see that the period of the repeating decimal of a fraction n⁄d will be (at most) the smallest number k such that 10k − 1 is divisible by d.
For example, the fraction 2⁄7 has d = 7, and the smallest k that makes 10k − 1 divisible by 7 is k = 6, because 999999 = 7 × 142857. The period of the fraction 2⁄7 is therefore 6.
In the case of a prime denominator (exluding 2 and 5) such as (1/p) , the period (number of digits in the recurring 'sequence') is always (p-1) or a divisor of (p-1).
For example, 1/7 = 0.142857... which has 7-1 = 6 recurring digits.
For example, 1/13 = 0.076923… which has (13-1)/2 = 6 recurring digits.
I don't know how you can decide (with 1/13 for example) if it's (13-1) or (13-1)/n though...
jemidiah
May 12th, 2008, 04:46 AM
In the case of a prime denominator (exluding 2 and 5) such as (1/p) , the period (number of digits in the recurring 'sequence') is always (p-1) or a divisor of (p-1).
I just thought I'd point out that this is a result of Fermat's Little Theorem (http://en.wikipedia.org/wiki/Fermat's_little_theorem) (I had to look it up to make sure it worked :) ). Even the cases where it doesn't work, 2 and 5, are accounted for since a and p have to be coprime.
As for finding the smallest k... I really have no idea. I never was very good at number theory. You might be able to use Euler's Theorem (http://en.wikipedia.org/wiki/Euler's_theorem) which happens to be a generalization of Fermat's Little Theorem; perhaps Nick or someone else could help apply it in this case.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.