Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 104/answer.txt

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions 104/question.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<body>
<div><div><div>
<p>The Fibonacci sequence is defined by the recurrence relation:</p>
<blockquote>F<sub><i>n</i></sub> = F<sub><i>n</i>−1</sub> + F<sub><i>n</i>−2</sub>, where F<sub>1</sub> = 1 and F<sub>2</sub> = 1.</blockquote>
<p>It turns out that F<sub>541</sub>, 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 F<sub>2749</sub>, which contains 575 digits, is the first Fibonacci number for which the first nine digits are 1-9 pandigital.</p>
<p>Given that F<sub><i>k</i></sub> is the first Fibonacci number for which the first nine digits AND the last nine digits are 1-9 pandigital, find <i>k</i>.</p>

</div><br>
<br></div>
</div>
</body>
</html>
22 changes: 22 additions & 0 deletions 104/solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
isPandigital = False
currentFiboNumber = 1
fn_minus1 = 1
fn_minus2 = 1
k = 2
blueprint = [1,2,3,4,5,6,7,8,9]

while not isPandigital:
currentFiboNumber = fn_minus1 + fn_minus2
fn_minus2 = fn_minus1
fn_minus1 = currentFiboNumber
k += 1
print(k)
if (len(str(currentFiboNumber)) >= 18):
stringNum = str(currentFiboNumber)
startList = [int(digit) for digit in stringNum[:9]]
startList.sort()
endList = [int(digit) for digit in stringNum[-9:]]
endList.sort()
isPandigital = (startList == endList) and (startList == blueprint)
print("Its the",k,"th element.")
print("The resulting number is:",currentFiboNumber)