// you’re reading...
1 Star2 Stars3 Stars4 Stars5 Stars (37 votes, average: 5.00 out of 5)
Loading...

Project Euler Solutions

Project Euler 129 Solution

Project Euler 129 Solution

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.

download arrowUse this link to get the Project Euler 129 Solution Python 2.7 source.

Afterthoughts

Project Euler 129 Solution last updated

Discussion

2 Responses to “Project Euler 129 Solution”

  1. Why do you need this check:
    “if is_prime(n)”?

    Posted by Carl | September 28, 2009, 6:38 AM

Post a comment