Go: package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n+1)
	a[0] = 1
	a[1] = 1
	for i := 2; i <= n; i++ {
		a[i] = a[i-1] + a[i-2]
	}
	fmt.Println(a[n])
}

C++: #include <bits/stdc++.h>
using namespace std;

// // TLEとなってしまう実装
// int fib(int n)
// {
//   // ベースケース
//   if (n == 0)
//   {
//     return 1;
//   }
//   if (n == 1)
//   {
//     return 1;
//   }
//   // 再帰ステップ
//   return fib(n - 1) + fib(n - 2);
// }

vector<int> F(100, 0);

int fib(int n)
{
  // n項目を計算済みのとき
  if (F.at(n) > 0)
  {
    return F.at(n);
  }
  // n項目を未計算のとき
  if (n == 0 || n == 1)
  {
    F.at(n) = 1;
  }
  else
  {
    F.at(n) = fib(n - 1) + fib(n - 2);
  }
  return F.at(n);
}

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

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

int F[SIZE];

int Fibonacci(int n)
{
    if (n == 1 || n == 0)
    {
        return F[n] = 1;
    }
    if (F[n])
    {
        return F[n];
    }
    return F[n] = Fibonacci(n - 1) + Fibonacci(n - 2);
}

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

    return 0;
}

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

int main()
{
	int n,x1=1,x2=1,tmp=0;
	cin >> n;
	
	if(n==0||n==1) cout << "1";
	else{
		for(;n>2;n--){
			tmp=x1+x2;
			x1=x2;
			x2=tmp;
		}
	}
	cout << x1 + x2;
}

C++: #include <bits/stdc++.h>
using namespace std;

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

	int ans = 1;
	if( n == 0 || n == 1 ) {
	}
	else {
		vector<int> dp( n + 1 );
		dp[0] = 1;
		dp[1] = 1;
		for( int i = 2; i < n + 1; i++ ) {
			dp[i] = dp[i - 1] + dp[i - 2];
		}
		ans = dp[n];
	}

	cout << ans << endl;
}

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

void fnInput(vector<int>& rvnFibDP)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  rvnFibDP.resize(nMaxSiz + 1, 0);

  if (nMaxSiz >= 1)  
    rvnFibDP[0] = rvnFibDP[1] = 1;
  else
    rvnFibDP[0] = 1;
}

int fnFibNumber(vector<int>& rvnFibDP, int nNo)
{
  if (rvnFibDP[nNo])  return rvnFibDP[nNo];

  return rvnFibDP[nNo] = 
         fnFibNumber(rvnFibDP, nNo - 1) + fnFibNumber(rvnFibDP, nNo - 2);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnFibDP; 

  fnInput(vnFibDP);
  cout << fnFibNumber(vnFibDP, vnFibDP.size() - 1) << endl;
  return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;


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

    vector<int> dp(n+1, 0);

    dp[0] = 1, dp[1] = 1;

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

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

C++: #include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>



using namespace std;

int main() {
   

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


}

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

unsigned long long ull[45];

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

C++: #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define M_P make_pair
#define P_B push_back
#define U_B upper_bound
#define L_B lower_bound
#define P_Q priority_queue
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout<<(x)<<endl
#define CIN(x) cin>>(x)
#define CIN2(x,y) cin>>(x)>>(y)
#define CIN3(x,y,z) cin>>(x)>>(y)>>(z)
#define CIN4(x,y,z,w) cin>>(x)>>(y)>>(z)>>(w)
#define SCAND(x) scanf("%d",&(x))
#define SCAND2(x,y) scanf("%d%d",&(x),&(y))
#define SCAND3(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define SCAND4(x,y,z,w) scanf("%d%d%d%d",&(x),&(y),&(z),&(w))
#define SCANLLD(x) scanf("%lld",&(x))
#define SCANLLD2(x,y) scanf("%lld%lld",&(x),&(y))
#define SCANLLD3(x,y,z) scanf("%lld%lld%lld",&(x),&(y),&(z))
#define SCANLLD4(x,y,z,w) scanf("%lld%lld%lld%lld",&(x),&(y),&(z),&(w))
#define PRINTD(x) printf("%d\n",(x))
#define PRINTLLD(x) printf("%lld\n",(x))
typedef long long int lli;
using namespace std;

int ctoi(char c)
{
  if( c >= '0' and c <= '9' )
    {
      return (int)(c-'0');
    }

  return -1;
}

int alphabet_pos(char c) 
{
  if( c >= 'a' and c <= 'z' )
    {
      return (int)(c-'a');
    }

  return -1;
}


int alphabet_pos_capital(char c)
{
  if( c >= 'A' and c <= 'Z' )
    {
      return (int)(c-'A');
    }

  return -1;
}


vector<string> split(string str, char ch)
{
  int first = 0;
  int last = str.find_first_of(ch);
  
  if(last == string::npos)
    {
      last = SIZ(str);
    }

  vector<string> result;

  while( first < SIZ(str) )
    {
      string Ssubstr(str, first, last - first);
      result.push_back(Ssubstr);
      first = last + 1;
      last = str.find_first_of(ch, first);

      if(last == string::npos)
	{
	  last = SIZ(str);
	}
    }
  
  return result;
}

/*--------------- the end of the template --------------------*/



vector<int> list;


int fibonacci( int n )
{
  if( n == 0 or n == 1 )
    {
      return list[n] = 1;
      
    }

  if( list[n] > 0 )
    {
      return list[n];
      
    }

  return list[n] = fibonacci(n-1) + fibonacci(n-2);
  
}





int main()
{
  //IOS; /* making cin faster */
  int n;
  SCAND(n);
  list = vector<int>(n,-1);
  
  PRINTD(fibonacci(n));
  
  
  

}

C++: #include <stdio.h>
int dp[50];
int fib(int n){
    if(n==0 || n==1) return dp[n]=1;
    else if(dp[n] != -1) return dp[n];  //已经计算过，直接返回结果，不重复计算
    else return dp[n] = fib(n-1) + fib(n-2);  //dp[n]记录fib(n)的值
}
int main(){
    int n;
    scanf("%d",&n);
    for (int i=0; i<50; i++) {
        dp[i] = -1;  //初始化为未计算
    }
    printf("%d\n",fib(n));
}