I'm trying to find the decimal representation minimal period of $1/n$ where $n$ is an integer.
I'll clarify colloquially because I'm very noob with math terms:
$$1/3 = 0,(3)$$ $$DP(3) = 1$$ $$1/7 = 0.(142857)$$ $$DP(7) = 6$$
After a long search on Wikipedia found that the period of $1/p$ where $p$ is prime equals to the multiplicative order of $10$ modulo $p$:
decimal_period = ->(p) do pwr = 1 pwr += 1 until ((10**pwr).modulo(p)) == 1 pwr end
This works for primes but I failed to find an algorithm for all other integers and I'm stuck here, any suggestion?