Go: // AOJ ALDS1_10_A: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_A

package main

import (
	"fmt"
)

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

func main() {
	var n int
	fmt.Scanf("%d", &n)
	fmt.Println(fibonacci(n))
}

Python: n = int(input())
F = [0] * 45

def fib(n) :
    if n == 0 or n == 1 :
        return 1
    else :
        if F[n] != 0 :
            return F[n]
        else :
            F[n] = fib(n - 1) + fib(n - 2)
            return F[n]
        
print(fib(n))

Python: n = int(input())

def fib(i):
    if i<=1:
        return 1
    
    else:
        a, b = 0, 1
        for i in range(n+1):
            c = b + a
            b = a
            a = c
        return c

print(fib(n))

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

Python: # ???????¨?????????????????§£???
# ?????°?????¨?????¢??????????????¨???????????¢????????£???


def fibonacci(n):
    num1 = 1
    num2 = 1
    tmp = 1

    for i in range(1, n):
        tmp = num1 + num2
        num1 = num2
        num2 = tmp

    return tmp


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

Python: #フィボナッチ数列
n = int(input())
dp = [0 for i in range(1000)]
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: n=int(input())

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

print(fib[n])

Python: F = [1,1]
for i in range(2, int(input())+1):
    F.append(F[i-2] + F[i-1])
print(F[-1])

Python: dp = [0]*50

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

print(fib(int(input())))

Python: class Fibonacci(object):
    record = [1, 1]
    
    def get_nth(self, n):
        if n < len(Fibonacci.record):
            return Fibonacci.record[n]
        
        for i in range(len(Fibonacci.record), n+1):
            result = Fibonacci.record[i-1] + Fibonacci.record[i-2]
            Fibonacci.record.append(result)
        
        return Fibonacci.record[n]
 
 
if __name__ == '__main__':
    num = int(input())
    f = Fibonacci()
    result = f.get_nth(num)
    print('{0}'.format(result))

Python: n = int(input())

fibs = [0 for _ in range(n+1)]
# checks = [False for _ in range(n+1)]

def fib(k):
    for i in range(k+1):
        if i == 0:
            fibs[i] = 1
        elif i == 1:
            fibs[i] = 1
        else:
            fibs[i] = fibs[i-1] + fibs[i-2]
    return fibs[k]

print(fib(n))

Python: from functools import lru_cache


@lru_cache(maxsize=None)
def fib(n):
    """ http://docs.python.jp/3/library/functools.html """
    if n < 2:
        return n
    return fib(n-1) + fib(n-2)


class Fibonacci(object):
    memo = [1, 1]

    def get_nth(self, n):
        if n < len(Fibonacci.memo):
            return Fibonacci.memo[n]
        # print('fib({0}) not found'.format(n))
        for i in range(len(Fibonacci.memo), n+1):
            result = Fibonacci.memo[i-1] + Fibonacci.memo[i-2]
            Fibonacci.memo.append(result)
            # print('fib({0})={1} append'.format(i, result))
        return Fibonacci.memo[n]


if __name__ == '__main__':
    # ??????????????\???
    num = int(input())

    # ?????£??????????????°????¨????
    # f = Fibonacci()
    # result = f.get_nth(num)
    result = fib(num+1)

    # ???????????????
    print('{0}'.format(result))

Python: f=[1,1]
for _ in[0]*43:f+=[f(-2)+f(-1)]
print(f[int(input())])

Python: n = int(input())

def fib(n):
    Fib = [1,1]
    if n == 0 or n == 1:
        return Fib[n]
    for i in range(2,n+1):
        Fib.append(Fib[i-1] + Fib[i-2])
    return Fib[n]

print(fib(n))

Python: import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

n = int(input())
dp = [0]*(1000001)
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: _fib = [None] * 44
_fib[0] = 1
_fib[1] = 1

def fib(n):
    if _fib[n] is None:
        _fib[n] = fib(n-1) + fib(n-2)
    return _fib[n]

_n = int(raw_input())
print(fib(_n))

Python: _fib = [1, 1]

def fib(n):
    if len(_fib) > n:
        return _fib[n]
    else:
        _fib[n] = fib(n-1) + fib(n-2)
        return _fib[n]

_n = int(raw_input())
print(fib(_n))

Python: n = int(input())
dp = {}
def fibonacci(n):
    if n == 0 or n == 1:
        return 1
    if n in dp:
        return dp[n]
    dp[n] = fibonacci(n-1) + fibonacci(n-2)
    return dp[n]
print(fibonacci(n))

Python: n=int(input())
if n == 1:
    print(1)
elif n == 2:
    print(2)
else:
    p=n+1 
    a=((1+5**(1/2))/2)**p
    b=((1-5**(1/2))/2)**p
    c=1/(5**(1/2))
    print(int(c*(a-b)))

Python: a = int(input())

memo = [0]*100000

def  fib(n):

    if n == 0 or n ==  1:
        memo[n] =1

    if memo[n] == 0:
        memo[n] = fib(n-2) + fib(n-1)
        return memo[n]
    else:
        return memo[n]



print(fib(a))

Python: N=int(input())
L=[0 for i in range(N+1)]
L[0]=1
L[1]=1
for i in range(2,N+1):
    L[i]=L[i-1]+L[i-2]
print(L[N])

Python: N = int(input())
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: n = int(input())
f = [1,1]
for i in range(n-1):
    fib = f[-1] + f[-2]
    f.append(fib)
print(f[n])

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

n=int(input())

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

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

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def fib_bad(n):
    if not n or n == 1:
        return 1
    return fib_bad(n - 2) + fib_bad(n - 1)


def fib_dp(n):
    fib_list[:1] = [1, 1]
    for i in range(2, n + 1):
        fib_list[i] = fib_list[i - 2] + fib_list[i - 1]
    return fib_list.pop()


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    index = int(_input[0])
    fib_list = [None] * index
    # print(fib_bad(index))
    print(fib_dp(index))

C++: #include <iostream>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
using namespace std;

long *memo;
long fib(long n){
	if(n < 2) return 1;
	return memo[n] != -1 ? memo[n] : (memo[n] = fib(n-1) + fib(n-2));
}

int main() {
	memo = new long[64];
	for(int i = 0; i < 64; i++){
		memo[i] = -1;
	}
	
	long n;
	cin >> n;
	cout << fib(n) << endl;
	return 0;
}

C++: #include <iostream>

using namespace std;

int num[47];

int fib(int n){
  if(num[n]!=0)return num[n];
  else return num[n] = fib(n-1) + fib(n-2);
}

int main(){
  int n;
  cin >> n;
  num[0] = 1;
  num[1] = 1;
  n = fib(n);
  cout << n << endl;
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int fibary[50];
    int n;
    cin >> n ;
    fibary[0]=fibary[1]=1;
    for(int i=2;i<=n;i++) {
        fibary[i]=fibary[i-1]+fibary[i-2];
    }
    cout << fibary[n] << endl;
    return 0;
}