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<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
ll dp[201];
int main(){
  ll a;cin>>a;
  dp[0]=1;
  dp[1]=1;
  for(ll i=2;i<=a;i++){
    dp[i]=dp[i-1]+dp[i-2];
  }
  cout<<dp[a]<<endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846

int main(){
	int n,i;
	cin>>n;
	vl dp(n+1);
	dp[0]=dp[1]=1;
	loop(i,2,n+1){
		dp[i]=dp[i-1]+dp[i-2];
	}
	cout<<dp[n]<<endl;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

const int NIL = -1;
const int MAX_N = 50;
vector<ll> fib(MAX_N);

int fibonach(vector<ll> &fib, int i){
    if(i == 0) return fib[0];
    if(i == 1) return fib[1];
    if(fib[i] != NIL) return fib[i];
    fib[i] = fibonach(fib, i-1) + fibonach(fib, i-2);
    return fib[i];
}

int main()
{
    int n; cin >> n;
    rep(i, MAX_N) fib[i] = NIL;
    fib[0] = 1;
    fib[1] = 1;
    ll res = fibonach(fib, n);
    cout << res << endl;
}

C++: #include <cstdio>

using namespace std;

int sum = 0, 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 );

    }

}

int main(){

    int n;

    scanf("%d", &n);

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

    int ans = fib(n);

    printf("%d\n", ans);

}

C++: #include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    int 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;
    return 0;
}

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

int main()
{
	int x = 1, y = 1, n, value = 0;
	cin >> n;

	if (n == 0 || n == 1) value = 1;
	else
	{
		while (n > 1)
		{
			value = x + y;
			x = y;
			y = value;
			n--;
		}
	}
	cout << value << endl;

	return 0;
}

C++: #include <iostream>

using namespace std;

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

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

C++: // DP(???????¨??????? Dynamic Programing)
// ????????±???????????¢???
// ?????£??????????????°???
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_A

#include <iostream>
using namespace std;

#define MAX_N 44

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

int n;
int fib(int);

int main()
{
    cin >> n;
    for(int i=0;i<MAX_N+1;++i)
        Memo[i].flg=false;
    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>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll dp[50];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    dp[0] = 1;
    dp[1] = 1;
    for (ll i = 2; i <= n; i++)
    {
        dp[i] = dp[i - 1] + dp[i - 2];
    }
    cout << dp[n] << endl;
}

C++: #include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll fib[50];
    ll n;
    cin>>n;
    fib[0]=fib[1]=1;
    for(int i=2;i<=n;i++){
    	fib[i]=fib[i-1]+fib[i-2];
    }
    cout << fib[n]<<endl;
    return 0;
}

C++: #include<iostream>
using namespace std;
 
typedef long long hyper;
 
hyper fib(int n)
{
    if(n < 2) return 1;
    if(n == 2) return 2;
    if(n == 3) return 3;
    return 3 * fib(n - 2) + fib(n - 4);
}
  
int main()
{
    int n;
    cin >> n;
    cout << fib(n) << endl;
    return 0;
}