Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	fmt.Println(fibonacci(n, make(map[int]int)))
}

func fibonacci(x int, memo map[int]int) int {
	if x == 0 || x == 1 {
		return 1
	}
	if y, ok := memo[x]; ok {
		return y
	}
	z := fibonacci(x-1, memo) + fibonacci(x-2, memo)
	memo[x] = z
	return z
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){

	int n;
	cin>>n;
	std::vector<int>a(n);
	a[0]=a[1]=1;
	for(int i=2;i<=n;i++)
		a[i]=a[i-1]+a[i-2];

	cout<<a[n]<<endl;
	
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int fib[45];
	int n,i;
	
	//???????????????
	for(int i=0; i<45; i++){
		fib[i]=0;
	}
	fib[0]=1;
	fib[1]=1;
	
	cin >> n;
	
	if(n!=0||n!=1){
		for(i=2;n>=i;i++){
			fib[i]=fib[i-1]+fib[i-2];
		}
	}
	
	cout << fib[n];
	return 0;
	
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>

using namespace std;


int main(){
	int n; cin >> n;

	int f1 = 1;
	int f2 = 1;
	int f3 = 0;
	for (int i = 2; i <= n; ++i){
		f3 = f1 + f2;
		f1 = f2;
		f2 = f3;
	}
	if (n == 1){
		cout << 1 << endl;
		return 0;
	}
	if (n == 2){
		cout << 2 << endl;
		return 0;
	}
	cout << f3 << endl;

	return 0;
}

C++: #include<iostream>
using namespace std;

int main() {
  int n, fib[50];

  cin >> n;

  fib[0] = 1;
  fib[1] = 1;
  for (int i = 2; i <= n; i++) {
    fib[i] = fib[i-2] + fib[i-1];
  }
  
  cout << fib[n] << endl;

  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

int fib(int n)
{
	int fibarray[45];
	for (int i = 0; i < n; i++)
	{
		fibarray[i] = 0;
	}
	fibarray[0] = 1;
	fibarray[1] = 1;

	for (int i = 2; i <= n; i++)
	{
		fibarray[i] = fibarray[i - 1] + fibarray[i - 2];
	}

	return fibarray[n];
}

int main()
{
	int n;
	cin >> n;

	cout << fib(n) << endl;

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector<long long> dp(50, -1);
int fib(int x) {
    if(dp[x] != -1) return dp[x];
    if(x == 0 || x == 1) return dp[x] = 1;
    return dp[x] = fib(x-1) + fib(x-2);
}

int main() {
    int n;
    cin >> n;
    cout << fib(n) << endl;
}

C++: #include<stdio.h>
#define MAX 44

int FN[MAX+1];

int main() {
    int i, n;
    FN[0] = FN[1] = 1;

    scanf("%d", &n);
    for (i=2; i<=n; i++) {
        FN[i] = FN[i-1] + FN[i-2];
    }

    printf("%d\n", FN[n]);

    return 0;
}

C++: #include<iostream>

using namespace std;

int fib(int n){
if(n<2)return 1;
return fib(n-1)+fib(n-2);
}

int main(void){

int n;

while(cin >> n)cout << fib(n) << endl;

return 0;
}

C++: #include <iostream>
using namespace std;
int memo[50];
int fib(int n)
{
	if(n == 0 || n == 1)	
		memo[n] = 1;
	
	if(memo[n] != 0)
	{
		return memo[n];
	}
	else 
	{
		memo[n] = fib(n - 1) + fib(n - 2);
		return memo[n];
	}
}

int main()
{
	int n;
	cin >> n;
	
	cout << fib(n) << endl;
	
	return 0;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9000000000000000000;
const double PI = acos(-1);

int fib[50];
int main() {
	int n;
	cin >> n;
	fib[0] = 0;
	fib[1] = 1;
	if (n < 2) {
		cout << fib[n] << endl;
		return 0;
	}
	for (int i = 2; i <= n+1; i++) {
		fib[i] = fib[i - 1] + fib[i - 2];
	}
	cout << fib[n+1] << endl;
}

C++: #include<iostream>
#include<vector>

using namespace std;

class Fibonacci{
private:
 vector< long > FN;
 long current;
public:
 Fibonacci( long num_0 = 1, long num_1 = 1, long max = 100 ) : current( 1 ), FN( max, 0 ){
  FN[ 0 ] = num_0;
  FN[ 1 ] = num_1;
 };

 void calculate( long num ){

 while( current < num )
  ++current;
  FN[ current ] = FN[ current-2 ] + FN[ current-1 ];
 };

 long get( long num ){
  if( current < num ) calculate( num );

  return FN[ num ];
 }
};

int main(){
 Fibonacci fn;

 long n = 0; cin >> n;

 cout << fn.get( n ) << endl;

 return 0;
};

C++: #include <iostream>
using namespace std;

int main(){
	
	int n;
	cin>>n;
	int F[n];
	F[0]=F[1]=1;
	for(int i=2;i<=n;i++)
		F[i]=F[i-1]+F[i-2];
		
	cout<<F[n]<<endl;
	
	return 0;
}

C++: #include <iostream>

int main(){
  int n;
  std::cin >> n;
  int dp[n+1];
  dp[0]=1; dp[1]=1;
  for(int i=2;i<=n;i++) dp[i]=dp[i-1]+dp[i-2];
  std::cout << dp[n] << std::endl;
}

C++: //AOJ斐波拉契数列问题
#include <iostream>
using namespace std;

int dp[45];//根据题目里给定限制 

int main(){
	
	int n;
	cin>>n;
	dp[1]=1;
	dp[2]=2;	
	for(int i=3;i<=n;i++){
		dp[i]=dp[i-1]+dp[i-2];
	}
	cout<<dp[n]<<endl;
	
	return 0;
}

C++: #include<iostream>

using namespace std;

int fib(int n) {
	if (n == 0)return 1;
	if (n == 1)return 1;
	return fib(n - 1) + fib(n - 2);
}
int main() {
	int n;

	cin >> n;

	cout << fib(n) << endl;

	return 0;
}

C++: // フィボナッチ数列
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 44
// 無効な値の定義
const int INV = -1;

// フィボナッチ数列を保持する配列
int fib[MAX_N + 1];

int Fibonacci(int n);

int main(void)
{

    int n;

    cin >> n;

    for(int i = 0; i < MAX_N + 1; i++)
    {
        fib[i] = INV;
    }

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

    // フィボナッチ数列の表示
    printf("%d\n", Fibonacci(n));

    return 0;
}

// フィボナッチ数列を算出する関数
int Fibonacci(int n)
{

    if( n <= 1)
    {
        // n = 0, n = 1 の時
        return 1;
    }

    if( fib[n] != INV )
    {
        // 既に計算されている時は, 結果を返す
        return fib[n];
    }

    // フィボナッチ数列の算出の算出
    fib[n] = Fibonacci(n - 2) + Fibonacci(n - 1);

    return fib[n];
}

C++: #include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int dp[45];
  dp[0]=dp[1]=1;
  for(int i=2;i<=45;i++) dp[i]=dp[i-1]+dp[i-2];

  cout<<dp[n]<<endl;
}

C++: #include<cstdio>
using namespace std;

int fib(int n);

int main() {
	int n;
	scanf("%d", &n);
	printf("%d\n", fib(n));
	return 0;
}

int fib(int n) {
	if (n == 0 || n == 1)return 1;
	else return fib(n - 1) + fib(n - 2);
}

C++: #include "bits/stdc++.h"
using namespace std;
int d;
int dd[50];
int fib(int a){
	if(a==0||a==1)return dd[a]=1;
	if(dd[a]!=-1)return dd[a];
	return dd[a]=fib(a-1)+fib(a-2);
}

int main() {
int c;
cin>>c;
for (int i = 0; i < 50; ++i) {
	dd[i]=-1;
}

cout<<fib(c)<<endl;
	return 0;
}

C++: #include <iostream>
using namespace std;

#define MAX_N 44

struct memo{
    int num;
    bool flg=false;
}Memo[MAX_N+1];

int n;
int fib(int);

int main()
{
    cin >> n;
    cout << fib(n);
    return 0;
}

int fib(int m){
    if(m == 0){
        if(!Memo[0].flg){
        Memo[0].num=1;
        Memo[0].flg=true;
        }
        return 1;
    }
    if(m == 1){
        if(!Memo[1].flg){
        Memo[1].num=2;
        Memo[1].flg=true;
        }
        return 1;
    }

    if(Memo[m].flg){
        return Memo[m].num;
    }
    else{
        Memo[m].num=fib(m-1) + fib(m-2);
        Memo[m].flg=false;
        return fib(m-1) + fib(m-2);
    }
}