January 2022 enrollments are closed and the course commences on 8th of January, 2022. For future cohorts Join the waitlist


#  Author: Arpit Bhayani
#  https://arpitbhayani.me

x = raw_input().split()

dp = {}

def fib(t1, t2, n):
    if n == 1:
        return t1

    if n == 2:
        return t2

    t3 = dp.get(n)
    if t3 is None:
        t3 = fib(t1, t2, n-2) + fib(t1, t2, n-1) ** 2
        dp[n] = t3

    return t3

print fib(int(x[0]), int(x[1]), int(x[2]))

470+ Competitive Programming Solutions

If you like what you read subscribe to my newsletter.

I write essays on various engineering topics and share it through my weekly newsletter 👇