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: 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])