Go: package main

import (
	"fmt"
)

func answer(n int) string {
	f := []int{1, 1}
	for i := 2; i <= n; i++ {
		f = append(f, f[i-1]+f[i-2])
	}

	return fmt.Sprintf("%d", f[n])
}

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println(answer(n))
}

Python: """
ALDS1_10_A
簡単な動的計画法を使ってフィボナッチ数列を計算する
"""
def Fibo(num):
    List = [None]*45
    for i in range(num+1):
        if i == 0:
            List[0] = 1
        elif i == 1:
            List[1] = 1
        else:
            List[i] = List[i-1]+List[i-2]
    return List

n = int(input())

print(Fibo(n)[n])

Python: def calculate(nums):
    nums = nums.append(nums[-2] + nums[-1])
    return nums

n = int(input())
number_list = [0,1]

while True:
    if len(number_list) == n+2:
        print(number_list[-1])
        break
    else:
        calculate(number_list)

Python: memo = {}

def fib(n):
    key = n
    
    if key in memo:
        return memo[key]
    
    if n == 0:
        return 1
    if n == 1:
        return 1
    if n > 1:
        memo[key] = fib(n-1) + fib(n-2)
    
    return memo[key]

n = int(input())
print(fib(n))

Python: n=int(input())
dp=[0]*(n+1)

for i in range(n+1):
    if i<=1:
        dp[i]=1
        continue

    dp[i]=dp[i-1]+dp[i-2]
print(dp[-1])

Python: n = int(input())

# 動的計画法
def fibonacci(n):
    F = [0]*(n+1)
    F[0] = 1
    F[1] = 1
    for i in range(2, n+1):
        F[i] = F[i-2] + F[i-1]
    return F

f = fibonacci(n)
print(f[n])

Python: n = int(input())

first = 1
second = 1
for i in range(n-1):
    second, first = first + second, second
print(second)

Python: n = int(input())
fib = [1,1]

if n>=2:
    for i in range(2,n+1):
        fib.append(fib[i-1]+fib[i-2])
        
print(fib[n])

Python: n = input()

if n == 0:
    print(1)
elif n == 1:
    print(1)
else:
    fib = [0 for i in range(n + 1)]

    fib[0] = 1
    fib[1] = 1

    for i in range(2, n + 1):
        print(i)
        fib[i] = fib[i - 1] + fib[i - 2]

    print(fib[n])

Python: 
def fib(n):
    if n == 1 or n == 2:
        return 1
    else:
        seq = [0 for _ in range(0, n)]
        seq[0], seq[1] = 1, 1
        for i in range(2, n):
            seq[i] = seq[i - 1] + seq[i - 2]
    return seq[n - 1]


n = int(input()) + 1
print(fib(n))

Python: n = int(input())
a0 = 1
a1 = 1

#print(a0, a1, end='')
if n == 0 or n == 1:
    a2 = 1

else:
    for i in range(n-1):
        a2 = a0 + a1
        a0 = a1
        a1 = a2
    #print('',a2,end='')
print(a2)

Python: target = int(input())
fib = [0 for n in range(target + 1)]
for i in range(target):
    if i == 0:
        continue
    elif i == 1:
        fib[i] = 1
    else:
        fib[i] = fib[i - 1] + fib[i - 2]
print(fib[target])

Python: MAXN = 45
fibs = [-1] * MAXN


def fib(n):
    """Returns n-th fibonacci number

    >>> fib(3)
    3
    >>> fib(10)
    89
    >>> fib(20)
    10946
    """
    if n == 0:
        return 1
    elif n == 1:
        return 1
    elif fibs[n] == -1: 
        fibs[n] = fib(n-1) + fib(n-2)

    return fibs[n]


def run():
    n = int(input())
    print(fib(n))


if __name__ == '__main__':
    run()

Python: a=[0]*45
a[0]=1
a[1]=1

for i in range(2,45):
    a[i]=a[i-1]+a[i-2]

n=int(input())
print(a[n])

Python: n=int(input())
x=0
y=1
if n==0 or n==1:
    print(1)
else:
    for i in range(n):
        x,y=y,x+y
        i+=1
    print(y)

Python: import sys
if __name__ == "__main__":
    n = int(input())
    if n == 0 or n == 1:
        print(1)
        sys.exit(0)
    dp = [0] * (n + 1)
    dp[0] = 1
    dp[1] = 1
    for i in range(2, n + 1):
        dp[i] = dp[i - 1] + dp[i - 2]
    print(dp[n])

Python: # -*- coding: utf-8 -*-


def main(n):
    lst = [1, 1]
    for i in range(2, n + 1):
        lst.append(lst[i - 1] + lst[i - 2])
    return lst[n]


if __name__ == '__main__':
    n = int(input())
    print(main(n))

Python: import sys
input = sys.stdin.readline
dp: list = [-1] * 50
def fib(n: int) -> int:
    if n == 0 or n == 1:
        dp[n] = 1
        return dp[n]
    elif dp[n] != -1:
        return dp[n]
    else:
        dp[n] = fib(n-1) + fib(n-2)
        return dp[n]

def main():
    n = int(input())
    print(fib(n))

if __name__ == '__main__': main()

Python: import numpy as np
import sys

def fib(n):
    if (n == 0):
        return 1
    elif (n == 1):
        return 1
    else :
        return fib(n - 1) + fib(n - 2)

if __name__ == "__main__":
    n = input("input number: ")
    n = int(n)
    #print(type(n))
    print(fib(n))

Python: def fib(n):
    global Fib
    if n <= 1:
        return 1
    elif Fib[n] != -1:
        return Fib[n]
    else:
        return fib(n-1) + fib(n-2)

def fib_eff(n):
    global Fib
    Fib[0] = 1
    Fib[1] = 1
    for i in range(2, n+1):
        Fib[i] = Fib[i-1] + Fib[i-2]

n = int(input())
Fib = [-1] * 45
fib_eff(n)
print(Fib[n])

Python: n = int(input())

if n == 0 or n == 1:
  print(1)
elif n == 2:
  print(2)
else:
  f = [1,1]
  for i in range(2, n+1):
    g = int(f[i-1]) + int(f[i-2])
    f.append(g)
  print(f.pop())

Python: def solve(n):
    dp=[1]*(n+1)
    for i in range(2,n+1):
        dp[i]=dp[i-1]+dp[i-2]
    return dp[n]
n=int(input())
print(solve(n))

Python: ii = lambda : int(input())
n = ii()
w = [-1]*50
w[0] = 1
w[1] = 1
for i in range(2,45):
    w[i]=w[i-2] + w[i-1]
print(w[n])

Python: def fib(n):

    if n ==0 or n ==1:
        return 1
    dp = [0] * (n+1)
    dp[0] = 1
    dp[1] = 1
    for i in range(2,n+1):
        dp[i] += dp[i-1] + dp[i- 2]
    return dp[n ]
# if __name__ == '__main__':
n=int(input())
print(fib(n))

Python: def fibonacci(F, n):
    if n == 0 or n == 1:
        F[n] = 1
        return F[n]
    if F[n]:
        return F[n]
    else:
        F[n] = fibonacci(F, n-1) + fibonacci(F, n-2)
        return F[n]

if __name__ == "__main__":
    n = int(input())
    F = []
    for _ in range(n+1):
        F.append(None)
    fibonacci(F, n)
    print(F[n])

Python: def fib(n):
    global f
    if f[n]==False:
        val=fib(n-1)+fib(n-2)
        f[n]=val
        return val
    else:
        return f[n]


n=int(input())
N=44+1
f=[1,1]
f.extend([0]*N)
fib(N)
print(f[n])

Python: import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())

fib = [1]*50

for i in range(N+2):
    fib[i+2] = fib[i] + fib[i+1]

print(fib[i-1])

Python: # フィボナッチ数列

n = int(input())
F = [0] * (n + 1)


def fibonacci(n):
    global F
    if n == 0 or n == 1:
        F.append(1)
        F.append(1)
        return 1
    if F[n] != 0:
        return F[n]
    F[n] = fibonacci(n - 1) + fibonacci(n - 2)
    return F[n]


ans = fibonacci(n)
print(ans)

Python: f=[0]*45
f[0]=f[1]=1

def fib(n):
    if n ==0 or n==1:
        return 1
    else:
        if f[n] == 0:
            f[n] = fib(n-1)+fib(n-2)
            return f[n]
        else:
            return f[n-1]+f[n-2]
n = int(input())
print(fib(n))

Python: # -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N=INT()

dp=[0]*50
dp[0]=dp[1]=1
for i in range(2, 50):
    dp[i]=dp[i-1]+dp[i-2]

print(dp[N])

Python: def fib(n):
    if n == 0 or n == 1:
        return 1
    if A[n] is not None:
        return A[n]
    A[n] = fib(n - 1) + fib(n - 2)
    return A[n]


A = [None] * (44 + 1)
n = int(input())
print(fib(n))