mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
Problem 234 project Euler (#883)
* Problem 234 project Euler * Update project_euler/problem_234 Co-Authored-By: Emmanuel Arias <emmanuelarias30@gmail.com> * Update project_euler/problem_234 Co-Authored-By: Emmanuel Arias <emmanuelarias30@gmail.com> * Update project_euler/problem_234 Co-Authored-By: Emmanuel Arias <emmanuelarias30@gmail.com> * Update project_euler/problem_234 Co-Authored-By: Emmanuel Arias <emmanuelarias30@gmail.com> * Update project_euler/problem_234 Co-Authored-By: Emmanuel Arias <emmanuelarias30@gmail.com> * Update project_euler/problem_234 Co-Authored-By: Emmanuel Arias <emmanuelarias30@gmail.com> * Update and rename problem_234 to problem_234.py * Made suggested changes else was not required temp declared afterwards suggested changes are correct.Thank u! * Rename project_euler/problem_234.py to project_euler/problem_234/sol1.py
This commit is contained in:
parent
1b3affc2ed
commit
6e2fb22f5e
32
project_euler/problem_234/sol1.py
Normal file
32
project_euler/problem_234/sol1.py
Normal file
@ -0,0 +1,32 @@
|
||||
# https://projecteuler.net/problem=234
|
||||
def fib(a, b, n):
|
||||
|
||||
if n==1:
|
||||
return a
|
||||
elif n==2:
|
||||
return b
|
||||
elif n==3:
|
||||
return str(a)+str(b)
|
||||
|
||||
temp = 0
|
||||
for x in range(2,n):
|
||||
c=str(a) + str(b)
|
||||
temp = b
|
||||
b = c
|
||||
a = temp
|
||||
return c
|
||||
|
||||
|
||||
q=int(input())
|
||||
for x in range(q):
|
||||
l=[i for i in input().split()]
|
||||
c1=0
|
||||
c2=1
|
||||
while(1):
|
||||
|
||||
if len(fib(l[0],l[1],c2))<int(l[2]):
|
||||
c2+=1
|
||||
else:
|
||||
break
|
||||
print(fib(l[0],l[1],c2+1)[int(l[2])-1])
|
||||
|
Loading…
Reference in New Issue
Block a user