Fibonacci Modified

I just solved a problem in HackerRank in Dynamic programming,so  that i want to share with you all.

Problem Statement Direct Link:Click here
I solved in python 3 and I hope it will be helpful to you.

Program Code:

t1, t2, n = map(int, input().split())
#get the input values
while n>2:
    temp = t2
    t2 = t1 + t2**2#logic
    n -= 1
    t1 = temp
print(t2)

Output:

0 1 10
84266613096281243382112

Comments

Popular posts from this blog

Artificial Intelligence

The taxonomy of CASE Tools

Zoho Second round - adding a digit to all the digits of a number