Hacker Rank Fibonacci Modified
# -*- coding: utf-8 -*-
"""
Created on 25-Aug-17 at 4:06 AM
@author: Pranta Sarker
Python Version 3
Task: Fibonacci Modified
"""
inp = input().split(' ');
inp = list(map(int , inp));
#print(inp);
t1 = inp[0];
t2 = inp[1];
n = inp[2];
#print('t1 = ' , t1 , ' t2 = ' , t2 , ' n = ' , n);
fibo = [];
fibo.append(t1);
fibo.append(t2);
for i in range(3 , n+1):
fibo.append(fibo[(i-2)-1] + (fibo[(i-1)-1]**2));
#print(fibo);
print(fibo[n-1]);
"""
Created on 25-Aug-17 at 4:06 AM
@author: Pranta Sarker
Python Version 3
Task: Fibonacci Modified
"""
inp = input().split(' ');
inp = list(map(int , inp));
#print(inp);
t1 = inp[0];
t2 = inp[1];
n = inp[2];
#print('t1 = ' , t1 , ' t2 = ' , t2 , ' n = ' , n);
fibo = [];
fibo.append(t1);
fibo.append(t2);
for i in range(3 , n+1):
fibo.append(fibo[(i-2)-1] + (fibo[(i-1)-1]**2));
#print(fibo);
print(fibo[n-1]);
Comments
Post a Comment