Go: package main

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

func main() {
	sc1 := bufio.NewScanner(os.Stdin)
	sc1.Split(bufio.ScanWords)
	sc1.Scan()
	num, _ := strconv.Atoi(sc1.Text())
	cache := make([]*int, num+1)
	fmt.Println(fib(num, cache))

}

func fib(n int, cache []*int) int {
	if n <= 1 {
		return 1
	}

 	if cache[n] != nil {
		return *(cache[n])
	}

	result := fib(n -2, cache) + fib(n -1, cache)
	cache[n] = &result
	return result
}

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);
    }
}

C++: #include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;


/*
DP
フィボナッチ数列

*/

int main(){

  int n;
  cin >> n;
  int fib[n+1];
  fib[0] = 1;
  fib[1] = 1;
  REP2(i,2,n+1){
    fib[i] = fib[i-1] + fib[i-2];
  }

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

C++: #include<stdio.h>

int dp[50];

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

int main() {
  int n, i;
  for ( i = 0; i < 50; i++ ) dp[i] = -1;

  scanf("%d", &n);
  printf("%d\n", fib(n));

  return 0;
}

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

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

}