Go: package main

import "fmt"

func fibonacci() func() int {
	x, y := 0, 1
	return func() int {
		x, y = y, x+y
		return x
	}
}
func main() {
	var n int

	fmt.Scan(&n)
	f := fibonacci()
	for i := 0; i < n; i++ {
		f()
	}
	fmt.Println(f())
}

C++: #include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
std::vector<ll> fib(51,-1);
ll ffib(int i){
    if(fib[i]==-1)fib[i]=ffib(i-1)+ffib(i-2);
    else return fib[i];
}
int main(){
    int n;
    std::cin >> n;
    fib[0]=1;fib[1]=1;
    ffib(50);
    std::cout << fib[n] << std::endl;
}

C++: #include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{int n;
cin>> n;
vector<int> dp(n+1);
rep(i,n+1)
{
 if(i==0||i==1)
 {dp.at(i)=1; continue;}
 dp.at(i)=dp.at(i-2)+dp.at(i-1);
}

cout<<dp.at(n)<<endl;
    return 0;
}

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

int dp[44];

int fib(int n) {
	if (dp[n] != -1)return dp[n];
	int res;

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

	dp[n] = res;
	return res;
}

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

	return 0;
}

C++: /*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;

using matrix = vector<V>;
matrix power(const matrix &a, int n)
{
    int sz = a.size();
    matrix res(sz, V(sz));
    rep(i, sz)
    rep(j, sz)
    {
        if (i == j)
            res[i][j] = 1;
        else
            res[i][j] = 0;
    }
    matrix r = a;
    while (n > 0)
    {
        if (n & 1)
        {
            matrix tmp(sz, V(sz, 0));
            rep(i, sz)
            rep(j, sz) rep(k, sz)
            {
                tmp[i][j] += res[i][k] * r[k][j];
            }
            res = tmp;
        }
        matrix tmp(sz, V(sz, 0));
        rep(i, sz)
        rep(j, sz)rep(k, sz)
        {
            tmp[i][j] += r[i][k] * r[k][j];
        }
        r = tmp;
        n >>= 1;
    }
    return res;
}

int fib(int n)
{
    matrix a(2, V(2));
    a[0] = {1, 1};
    a[1] = {1, 0};
    a = power(a, n - 1);
    V start = {1, 1};
    V res(2, 0);
    rep(i, 2)
    rep(j, 2)
    {
        res[i] += a[i][j] * start[j];
    }
    return res[0];
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << fib(n) << endl;
}

C++: #include <iostream>
#include<math.h>
using namespace std;
int a[45];
int n;
int fib(int n){
    if(a[n-1]!=0){
    }else{
        a[n-1]=fib(n-1);
    }if(a[n-2]!=0){
    }else{
        a[n-2]=fib(n-2);
    }
    if(n==1)return 1;
    if(n==0)return 1;
    return a[n-1]+a[n-2];
}
    
int main(){
   
    cin >> n;
    fib(n);
    cout <<fib(n) <<endl;
}

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

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

C++: #include<iostream>
using namespace std;
long long n, f[45];
void fibonacci() {
	f[0] = f[1] = 1;
	for (int i = 2; i < 45; i++)
		f[i] = f[i - 1] + f[i - 2];
}
int main() {
	fibonacci();
	cin >> n;
	cout << f[n] << endl;
}

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

using namespace std;

static vector<int> M(44, 0);

static inline int fibonacci(int n) {
  if (n == 0 || n == 1) {
    return 1;
  } 

  if (M[n] != 0) {
    return M[n];
  } 
  M[n] = fibonacci(n - 2) + fibonacci(n - 1);
  return M[n];
}

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

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    int fib[n+1];
    fib[0] = 1;
    fib[1] = 1;
    REP(i,n - 1){
        fib[i+2] = fib[i+1] + fib[i];
    }
    cout << fib[n] << endl;

}