Wednesday, November 9, 2016

Hackerrank - Algorithm - Fibonacci Modified

 Hackerrank - Algorithm - Fibonacci Modified
Given terms  and  where , term  is computed using the following relation:
For example, if term  and , term , term , term , and so on.
Given three integers, , and , compute and print term  of a modified Fibonacci sequence.

-----------------------------------------------------------------------------------------
Source Code:
t1,t2,n = map(int,raw_input().split())
for i in range(1,n-1):
    ans = t1 + t2**2
    t1 = t2
    t2= ans
print(ans)
------------------------------------------------------------------------------------------------------
#hackerrank #algorithm #fibonaccimodified #solution #sourcecode #python #submission

No comments:

Post a Comment

Two Sum

Given an array of integers, return indices of the two numbers such that they add up to specific target. You may assume that each input w...