Take the 2-minute tour ×  Possible Duplicate: Upper bound/exact
length of decimal expansion of simple fraction  I noticed that
WolframAlpha given an operation like $\frac{n}{m},\;n,m \in N$
that result in a periodic decimal number, computes really fast
the length of the period.  E.g. $\frac{3923}{6173}$ has a period
of 3086: here.  I was wondering how this computation is done: is
there some method to do this (except the trivial one of
executing the division and looking for a sequence repetition) ?
share|improve this question Note: i'm not a mathematician, I
apologize if I have done some mistake with names, tags, etc.. – 
Aslan986 May 3 '12 at 20:54 add comment  marked as duplicate by
Ross Millikan, sdcvvc, William, t.b., rschwieb Sep 14 '12 at
16:39   3 Answers  up vote 3 down vote accepted  The period is
always a factor of the totient of the denominator. In your
example, 6173 is prime, so its totient is 6172 and half of that
is 3086. I suspect Alpha is just doing the long division. When
the remainder at any