Go: package main

/*
フィボナッチ数列
*/

import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func fibWithMemo(n int, memo map[int]int) int {
	if n == 0 || n == 1 {
		return 1
	}
	if val, ok := memo[n]; ok {
		return val
	}
	memo[n] = fibWithMemo(n-1, memo) + fibWithMemo(n-2, memo)
	return memo[n]
}

func fib(n int) int {
	memo := make(map[int]int)
	return fibWithMemo(n, memo)
}

func main() {
	scanner := makeScanner(1024)
	n := eGetInt(scanner)
	fmt.Println(fib(n))
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

type ints []int

func (s ints) String() string {
	var buf bytes.Buffer
	buf.WriteString("[")
	sep := ""
	for _, v := range s {
		buf.WriteString(fmt.Sprintf("%s%d", sep, v))
		sep = ", "
	}
	buf.WriteString("]")
	return buf.String()
}

func reverse(a ints) ints {
	r := make(ints, len(a))
	for i := 0; i < len(a); i++ {
		r[i] = a[len(a)-1-i]
	}
	return r
}
func max(a ints) (int, bool) {
	if len(a) == 0 {
		return 0, false
	}
	m := a[0]
	for _, e := range a {
		if e > m {
			m = e
		}
	}
	return m, true
}
func min(a []int) int {
	m := a[0]
	for _, v := range a {
		if v < m {
			m = v
		}
	}
	return m
}

func sum(a ints) int {
	if len(a) == 0 {
		return 0
	}
	sum := 0
	for _, e := range a {
		sum += e
	}
	return sum
}
func find(n int, a ints) int {
	for i, v := range a {
		if n == v {
			return i
		}
	}
	return -1
}

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

Python: A = {}
def fibonacci(n):
    global A
    if n == 0 or n == 1:
        A[n] = 1
        return A[n]
    if n in A:
        return A[n]
    else:
        A[n] = fibonacci(n - 2) + fibonacci(n - 1)
        return A[n]

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

Python: def fib(n):
    if n == 0 or n == 1:
        return 1
    return fib(n-1) + fib(n-2)

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

Python: N = int(input())

DP = [0 for _ in range(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())

from functools import lru_cache
@lru_cache(maxsize=None)
def fibo(n: int):
    if n == 0 or n == 1:
        return 1
    return fibo(n-1) + fibo(n-2)

print(fibo(n))

Python: def fib(a, b, fiboli):
    if len(fiboli) < n:
        fiboli.append(fiboli[-1] + fiboli[-2])
        fib(fiboli[-1], fiboli[-1] + fiboli[-2], fiboli)
    else:
        print(fiboli[-1])
        print(fiboli)

# n = 4
n = int(input())
if n == 0 or n == 1:
    print(1)
elif n == 2:
    print(2)
else:
    fibo_list = []
    fibo_list.append(n - 1)
    fibo_list.append(n - 2)
    fib(n - 1, n - 2, fibo_list)

Python: f=[None for i in range(45)]

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

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


if __name__ == "__main__":
    main()

Python: MAX_N = 44
_memo = [None for _ in range(MAX_N + 1)]
_memo [0] = _memo[1] = 1

def fibonacci(n):
    
    if _memo[n] is not None:
        return _memo[n]
    else:
        _memo[n] = fibonacci(n - 1) + fibonacci(n - 2)
        return _memo[n]

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

Python: def fibn(n):
    fib = [1,1]
    for i in range(2,n+1):
        fib.append(fib[i-2] + fib[i-1])
    return fib[n]
    
n = int(input())
print(fibn(n))

Python: from functools import lru_cache
n = int(input())

@lru_cache(maxsize=None)


def fib(n):
    if n==0 or n==1:
        return 1
   
    else:
        return fib(n-1)+fib(n-2)
        
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: n=int(input())
fib = [1,1]

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

Python: def fib(n):
    n=int(n)
    F=[1,1]
    if n>=2:
        for i in range(1,n):
            F.append(F[i-1]+F[i])
    
    return F[n]
    
a=input(int())
fib(a)

Python: a=b=1
for i in range(int(input())):
    a,b=b,a+b
print(a)

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

import sys
import re
import math
import itertools
import functools
import logging

logging.basicConfig(level=logging.DEBUG, format="DBG: %(message)s")

def dbg(msg, *args, **kwargs):
    logging.debug(msg, *args, **kwargs)

def fib(n):
    assert n >= 0

    f0 = 1
    f1 = 1

    if n == 0: return f0
    if n == 1: return f1

    for _ in range(n-1):
        f2 = f1 + f0
        f0 = f1
        f1 = f2

    return f2

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

    print(fib(n))

if __name__ == "__main__": main()

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

import sys


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


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    index = int(_input[0])
    print(fib_1(index))

Python: def fibonacci_dp(n,lf):
    if n == 0 or n == 1:
        return lf[n]
    if n < len(lf):
        return lf[n]
    lf.insert(n,fibonacci_dp(n-2,lf) + fibonacci_dp(n-1,lf))
    return lf[n]

if __name__ == "__main__":
    n = int(input())
    lf = [1,1,]
    print(fibonacci_dp(n,lf))

Python: def make_fibonacchi(n: int):
    
    res = {}
    
    res[0] = 1
    res[1] = 1
    
    if n == 0 or n == 1:
        return 1
    
    for i in range(2, n + 1):
        res[i] = res[i-1] + res[i-2]
    
    return res[n]


n = int(input())
print(make_fibonacchi(n))

Python: n = int(input())

A = []
A.append(1)
A.append(1)

if n>1:
    for i in range(n-1):
        A.append(A[i]+A[i+1])

print(A[n])