project_euler.problem_129.sol1

Project Euler Problem 129: https://projecteuler.net/problem=129

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.

Functions

least_divisible_repunit(→ int)

Return the least value k such that the Repunit of length k is divisible by divisor.

solution(→ int)

Return the least value of n for which least_divisible_repunit(n)

Module Contents

project_euler.problem_129.sol1.least_divisible_repunit(divisor: int) int

Return the least value k such that the Repunit of length k is divisible by divisor. >>> least_divisible_repunit(7) 6 >>> least_divisible_repunit(41) 5 >>> least_divisible_repunit(1234567) 34020

project_euler.problem_129.sol1.solution(limit: int = 1000000) int

Return the least value of n for which least_divisible_repunit(n) first exceeds limit. >>> solution(10) 17 >>> solution(100) 109 >>> solution(1000) 1017