프로그래밍/HackerRank

[HackerRank][Python3] Recursion: Fibonacci Numbers

snoopybox 2018. 7. 20. 23:01

Problem :

https://www.hackerrank.com/challenges/ctci-fibonacci-numbers/problem


My Solution :

#!/usr/bin/env python3


def fibonacci(n):
    a, b = 0, 1
    for i in range(2, n+1):
        a, b = b, a+b
    return b


n = int(input())
print(fibonacci(n))