master
MitchellHansen 8 years ago
parent 44358923e3
commit 13a163e81d

@ -0,0 +1,24 @@
# The Fibonacci sequence is defined by the recurrence relation:
#
# Fn = Fn1 + Fn2, 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

@ -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)
Loading…
Cancel
Save