## A number consisting entirely of ones is called a repunit. We shall define $R(k)$ to be a repunit of length $k$; for example, $R(6) = 111111$.

Given that $n$ is a positive integer and $\gcd(n, 10) = 1$, it can be shown that there always exists a value, $k$, for which $R(k)$ is divisible by $n$, and let $A(n)$ be the least such value of $k$; for example, $A(7) = 6$ and $A(41) = 5$.

The least value of $n$ for which $A(n)$ first exceeds ten is $17$.

Find the least value of $n$ for which $A(n)$ first exceeds one-million.

### This problem comes under the field of number theory.

There are several paths to tackling this problem, one of which involves Euler’s Theorem, which asserts that for $gcd(a, n) = 1$, $a^{\phi(n)}=\equiv 1\pmod n$, where $\phi(n)$ is Euler’s Totient function.

Let me preface that this problem involves some techniques not commonly taught in standard mathematics curriculum, but prominent in competition mathematics.

Since $gcd(n,10)=1$, Euler’s Theorem is applicable. The problem then is to find the smallest $k$ such that $10^k=\equiv 1\pmod n$. We are actually trying to find the order of 10 modulo n. We wish to find the smallest n such that its order is greater than 10^6.

By Fermat-Euler’s Theorem, we know that such a k must divide $\phi(n)$. Thus, since $\phi(n)

Euler’s totient function is multiplicative. In general, it’s challenging to find a number n such that $\phi(n)$ equals a fixed number, but it’s easier to work with primes.

Let’s consider a prime $p$. $\phi(p^m) = (p-1)*p^{m-1}$.

From this function, it’s clear that if $p^m >10^6$ for some prime $p$, then $\phi(p^m)<10^6$, because $p-1 < p$. Hence, we only consider primes less than $10^6$.
For $p$ being prime $p^a$ and $q^b$ with $p\neq q$ primes, $\phi(p^a*q^b)=(p-1)*p^{a-1}*(q-1)*q^{b-1}=n*\phi(n)/pq$. Since $\phi(n)

The smallest two odd prime numbers are 3 and 5. Choosing these numbers, we get the smallest composite odd number $n=15$, which does not divide 10.

Then, $2^{\phi(15)} = 2^8 \equiv 1 \pmod{15}$, and $\phi(15)>10^6$, but 2^8 does not succeed 10^6.

Therefore, we must choose the next prime $p=3$, and $q=7$. So, $n=21$. This choice satisfies $\phi(p*q)>10^6$. Let’s verify it:

The order of 10 (mod 21) is 6, which is less than a million. Therefore, the condition is met, and the solution to the problem is n = 21.

This problem is a blend of modular arithmetic, Euler’s Totient function and properties of prime numbers.

##### More Answers:

Cuboid LayersABC Hits

Hexagonal Tile Differences