From 13a163e81de0b9710c7559b67ab45f3312e7faec Mon Sep 17 00:00:00 2001 From: MitchellHansen Date: Mon, 13 Mar 2017 23:25:52 -0700 Subject: [PATCH] problem 25 --- problem_25.py | 24 ++++++++++++++++++++++++ problem_26.py | 25 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 problem_26.py diff --git a/problem_25.py b/problem_25.py index e69de29..539a746 100644 --- a/problem_25.py +++ b/problem_25.py @@ -0,0 +1,24 @@ + +# The Fibonacci sequence is defined by the recurrence relation: +# +# Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. +# +# The 12th term, F12, is the first term to contain three digits. +# +# What is the index of the first term in the Fibonacci sequence to contain 1000 digits? + +n_minus_1 = 1 +n_minus_2 = 1 +value = 0 +index = 3 + +while True: + + value = n_minus_1 + n_minus_2 + if len(str(value)) == 1000: + print(index) + break + + n_minus_2 = n_minus_1 + n_minus_1 = value + index += 1 diff --git a/problem_26.py b/problem_26.py new file mode 100644 index 0000000..0a0b675 --- /dev/null +++ b/problem_26.py @@ -0,0 +1,25 @@ + +# A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given: +# +# 1/2 = 0.5 +# 1/3 = 0.(3) +# 1/4 = 0.25 +# 1/5 = 0.2 +# 1/6 = 0.1(6) +# 1/7 = 0.(142857) +# 1/8 = 0.125 +# 1/9 = 0.(1) +# 1/10 = 0.1 + +# Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring cycle. +# +# Find the value of d < 1000 for which 1/d contains the longest recurring cycle in its decimal fraction part. + +def longest_permutation(input): + + return input + +i = str(1.0/7.0) +print(i) +if "142857" in i: + print(True) \ No newline at end of file