Wikipedia states here:
For an arbitrary integer $n$ the length $\lambda (n)$ of the repetend of $1/n$ divides $\phi (n)$, where $\phi$ is the totient function.
In the next section, it defines $\lambda(n)$ as Carmichael's Function:
λ(n) is the least common multiple of the λ of each of its prime power factors:
$\lambda (n)=lcm (\lambda (p_{1}^{r_{1}}),\lambda > (p_{2}^{r_{2}}),\dots, \lambda (p_{k}^{r_{k}}))$
- I want to know if the two different functions symbolized by $\lambda(n)$ are the same. If so, it seems to me that I can use Carmichaels Function as a generic method to write an algorithm that determines if $1/n$ repeats, and if it does I want it to give an accurate length of the repetend.
- If they are the same, is the article correct in its statement that $n$ is totally arbitrary? In other words, can I use this function in general?
I am not a pure math guy. I am simply trying to apply theorems I am reading online to solve a problem. Please keep that context in mind when you answer :)
So far my algorithm determines repetition, but it appears that most of my lengths are wrong. This could be a bug in my code, or it could be my misunderstanding of the wikipedia article. Here are some of my results for $n \in \{2,\dots 11,\}$
Fraction: 1/2
factors of 2 are [2]
1/2 is not repeating
Fraction: 1/3
factors of 3 are [3]
1/3 is repeating: 0.3333333333333333
length of repetition is 2
Fraction: 1/4
factors of 4 are [2, 2]
1/4 is not repeating
Fraction: 1/5
factors of 5 are [5]
1/5 is not repeating
Fraction: 1/6
factors of 6 are [2, 3.0]
1/6 is repeating: 0.16666666666666666
length of repetition is 2
Fraction: 1/7
factors of 7 are [7]
1/7 is repeating: 0.14285714285714285
length of repetition is 6.0
Fraction: 1/8
factors of 8 are [2, 2, 2]
1/8 is not repeating
Fraction: 1/9
factors of 9 are [3, 3]
1/9 is repeating: 0.1111111111111111
length of repetition is 6.0
Fraction: 1/10
factors of 10 are [2, 5.0]
1/10 is not repeating
Fraction: 1/11
factors of 11 are [11]
1/11 is repeating: 0.09090909090909091
length of repetition is 10.0