## Project Euler 129: Investigating minimal repunits that are divisible by n

#### Problem Description

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.

#### Analysis

This was an obvious solution to the problem. Still not sure about the relevance of repunits so we just took the recreational approach and created a set of solutions that are easy to follow.

#### Project Euler 129 Solution

Runs < 0.001 seconds in Python 2.7.Use this link to get the Project Euler 129 Solution Python 2.7 source.

#### Afterthoughts

- Functions
`is_prime, gcd`

are listed in Common Functions and Routines for Project Euler

*Project Euler 129 Solution last updated*

Why do you need this check:

“if is_prime(n)”?

Actually, you don’t. It just saved time from considering irrelevant values of n. It can be removed, but the ‘A’ function may take longer.