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())
memo = [-1 for i in range(n+1)]

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

print(fib(n))

Python: def fib(n,memo={}):
    if n == 0:
        return 1
    elif n == 1:
        return 1
    elif n in memo:
        return memo[n]
        
    else:
        memo[n]=fib(n-1,memo)+fib(n-2,memo)
        return memo[n]
a=int(input())
print(fib(a))

Python: answer_list = [1, 1] + [None] * 43

def fib(num):
    ans = answer_list[num]
    if ans:
        return ans
    ans = fib(num - 1) + fib(num - 2)
    answer_list[num] = ans
    return ans


n = int(input)

print(fib(n))

Python: N = int(input())
F = [0 for i in range(N+1)]


def fib(n):
    if n == 0 or n == 1:
        F[n] = 1
        return F[n]

    if F[n]:
        return F[n]

    F[n] = fib(n-2) + fib(n-1)
    return F[n]


def main():
    print(fib(N))


if __name__ == '__main__':
    main()

Python: def fibonacci(n):
    a, b = 1, 1
    for i in range(n-1):
        a, b = b, a+b

    return b

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

Python: import math
n = int(input())
print(round((pow((1+math.sqrt(5))/2,n) - pow((1-math.sqrt(5))/2,n)) / math.sqrt(5)))

Python: class Fibonacci(object):
    memo = [1, 1]
    def __init__(self):
        pass

    def get_nth(self, n):
        if n <= len(Fibonacci.memo):
            return Fibonacci.memo[n]
        for i in range(len(Fibonacci.memo), n+1):
            result = Fibonacci.memo[i-1] + Fibonacci.memo[i-2]
            Fibonacci.memo.append(result)
        return Fibonacci.memo[n]


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

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

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

Python: def fib(n):
    l = [0]*(n+1)
    l[0] = 1
    l[1] = 1
    for i in range(2, n+1):
        l[i] = l[i-1] + l[i-2]
    return l[n]

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

Python: n = int(input())

l = [1,1]

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

Python: import numpy as np
import sys
f = [-1 for i in range(45)]
f[0] = f[1] = 1

def fib(n):
    global f
    for i in range(2,n+1):
        f[i] = f[i - 1] + f[i - 2]
        #print(i,f[i])
    return f[n]

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

Python: def fib(n):
    l = [0] * (n + 1)
    l[0] = 1
    l[1] = 1

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

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

main()

Python: N = int(input())
a = b = 1
while N:
    a, b = b, a+b
    N -= 1
print(a)

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

Python: n = int(input())

# dpテーブルの用意
dp = [-1]*(n+1)

# dpの初期値
dp[0], dp[1] = 1, 1

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

print(dp[-1])

Python: def dynamic(n):
    if n == 0 or n == 1:
        return 1
    if F[n] != 0:
        return F[n]
    F[n] = dynamic(n - 1) + dynamic(n - 2)
    return F[n]

if __name__ == '__main__':
    n = int(raw_input())
    print(dynamic(n))

Python: import sys
input = sys.stdin.readline


def inpl():
    return list(map(int, input().split()))


def f(n):
    if n < 2:
        return 1
    ret = [0] * (n + 1)
    ret[0] = 1
    ret[1] = 1
    for i in range(2, n + 1):
        ret[i] = ret[i - 2] + ret[i - 1]
    return ret[n]


print(f(int(input())))

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


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

def fib_memo(n, memo):
    if n == 0 or n == 1:
        memo[n] = 1
        return memo[n]
    if memo[n] != -1:
        return memo[n]
    memo[n] = fib_memo(n-1, memo) + fib_memo(n-2, memo)
    return memo[n]

memo = [-1 for i in range(45)]

n = int(input())
print(fib_memo(n, memo))

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

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

Python: n = int(input())
fn0 = 1
fn1 = 1
if n == 0:
    fn = fn0
elif n == 1:
    fn = fn1
else:
    for ni in range(2, n+1):
        fn = fn0 + fn1
        fn0 = fn1
        fn1 = fn
print(fn)

Python: from functools import lru_cache


@lru_cache(maxsize=None)
def fibo(n):
    if n == 0 or n == 1:
        return 1

    return fibo(n - 1) + fibo(n - 2)


n = int(input())

print(fibo(n))

Python: def fibonacci(n, l):
  if n <= 1:
    l[n] = 1
    return l[n]
  elif l[n] != 0:
    return l[n]
  else:
    l[n] = fibonacci(n-1, l) + fibonacci(n-2, l)
    return l[n]


n = int(input())
l = [0] * (n+1)
print(fibonacci(n, l))

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

print( Fibonacci( int(input()) ) )

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: def fib(n):
  if n < 0:
    print("error")
    exit()
  if n < 2:
    result = 1
  result = fib(n-1) + fib(n-2)
  return result

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