project_euler.problem_104.sol1

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

The Fibonacci sequence is defined by the recurrence relation:

Fn = Fn-1 + Fn-2, where F1 = 1 and F2 = 1. It turns out that F541, which contains 113 digits, is the first Fibonacci number for which the last nine digits are 1-9 pandigital (contain all the digits 1 to 9, but not necessarily in order). And F2749, which contains 575 digits, is the first Fibonacci number for which the first nine digits are 1-9 pandigital.

Given that Fk is the first Fibonacci number for which the first nine digits AND the last nine digits are 1-9 pandigital, find k.

Functions

check(→ bool)

Takes a number and checks if it is pandigital both from start and end

check1(→ bool)

Takes a number and checks if it is pandigital from END

solution(→ int)

Outputs the answer is the least Fibonacci number pandigital from both sides.

Module Contents

project_euler.problem_104.sol1.check(number: int) bool

Takes a number and checks if it is pandigital both from start and end

>>> check(123456789987654321)
True
>>> check(120000987654321)
False
>>> check(1234567895765677987654321)
True
project_euler.problem_104.sol1.check1(number: int) bool

Takes a number and checks if it is pandigital from END

>>> check1(123456789987654321)
True
>>> check1(120000987654321)
True
>>> check1(12345678957656779870004321)
False
project_euler.problem_104.sol1.solution() int

Outputs the answer is the least Fibonacci number pandigital from both sides. >>> solution() 329468