I am working on a project for school in which I would need to sum up hundreds of rational values to over one trillion sig figs (done in code) however it is not practical to store each term in the sequence as the file will become to large, however because all of the numbers are rational they are either finite, which is better, or they are infinite, but still rational so they have to repeat, so my question is: is there a mathematical way to tell the length of the pattern, for example 1/14 is 0.0[714285][714285] with the [714285] bit repeating infinite times.
any help would be much appreciated Thank you in advance!!
To find the length of the periodic part of the decimal expansion for $\frac ab$ (where $a$ and $b$ have no common factors): first remove all the factors of $2$ and $5$ from $b$ (that is, evenly divide $b$ by $2$ and by $5$ as often as possible); then, if $b'$ is the result of removing the $2$s and $5$s, then calculate the smallest positive integer $n$ such that $10^n-1$ is divisible by $b'$ (this is the "multiplicative order" of $10$ modulo $b'$). Then $n$ is the length of the periodic part of $\frac ab$. The largest it can ever be is $b'-1$.