This problem is based on non-terminating, repeating decimal points.
Let \$n\$ be any positive integer \$(n > 1 \text{ and } n < 10000)\$, say \$7\$. Then, \$1/n = 1/7 = 0.142857142857142857...\$
We see a pattern like, 0. 142857 142857 142857 ...
In this, the 142857
part is always repeating, which has length of \$6\$. Or, if \$n = 11\$, then \$1/n = 1/11 = 0.0909090909090909...\$
Here the length of the pattern is 2
. So, here goes the problem!
Task
Given a positive integer \$n\$, \$(n > 1 \text{ and } n < 10000)\$, find the length of pattern in \$1/n\$, if it's repeating. Otherwise, return any non-positive integer (e.g., cases: \$1/5, 1/94, 1/22\$). Note that, the pattern should start just after the decimal point. Hint: \$1/22 = 0.04545454545454545454545\$.
Sample I/O
5 -> -1
13 -> 6
21 -> 6
27 -> 3
33 -> 2
37 -> 3
94 -> -1
22 -> -1
69 -> 22
197 -> 98
65 -> -1
- \$1/9979\$
- \$1/9967\$
This is a code-golf, so the fewest bytes will win!