• + 1 comment

    simple recurrance relation formula

    maths

    def solve(a, b, n):
        x = (1+sqrt(5))/2
        y = (1-sqrt(5))/2
    
        first = ((a/2)*(1-(1/sqrt(5))) + (b/sqrt(5))) * (x)**n
    
        second = ((a/2)*(1+(1/sqrt(5))) - (b/sqrt(5))) * (y)**n
    		
    		return int((first+second).real)
    # 		why this shows me wrong but answer is correct
    
        ans = first + second
        return str(int(ans.real))