Go: package main

import (
	"fmt"
)

const MAX = 45

var dp [MAX]int

func fin(n int) int {
	if dp[n] != 0 {
		return dp[n]
	}

	switch n {
	case 0:
		dp[n] = 1
	case 1:
		dp[n] = 1
	default:
		dp[n] = fin(n-1) + fin(n-2)
	}
	return dp[n]
}

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

C++: #include <bits/stdc++.h>
using namespace std;
#define MAX 50
int fibonacci(int);
int F[MAX];

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

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

C++: // -*- coding: utf-8 -*-
// Last-Updated : <2014/06/20 08:35:59 by samui>

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <bitset>

#define MP(a, b) std::make_pair(a, b)
#define X first
#define Y second
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); ++(i))
#define rer(i,l,n) for(int (i) = l; (i) <= (int)(n); ++(i))
#define reu(i,l,n) for(int (i) = l; (i) < (int)(n); ++(i))
template<typename T,typename U> inline void amin(T &x,U y){ if(y<x) x = y;}
template<typename T,typename U> inline void amax(T &x,U y){ if(x<y) x = y;}
template<typename TYPE,std::size_t SIZE>
std::size_t len(const TYPE (&array)[SIZE]){return SIZE;}

// 幾何ライブ
typedef long double LD;
const LD INF = 1e100;
const LD EPS = 1e-8;
const LD PI = acos(-1);
typedef std::pair<LD,LD> PLD;
typedef std::vector<std::pair<LD,LD>> VPLD2;

class Point{
public:
  LD x,y;
  Point(LD x = 0,LD y = 0): x(x),y(y){ };
  Point operator + (Point p) {return Point(x+p.x,y+p.y);};
  Point operator - (Point p) {return Point(x-p.x,y-p.y);};
  Point operator * (LD a) {return Point(x*a,y*a);};
  Point operator / (LD a) {return Point(x/a,y/a);};
  LD abs(){return std::sqrt(x*x+y*y);};
  Point unit(){LD u = abs();return Point(x,y)/u; };
};
typedef Point Vector2D;
LD dotProduct(const Vector2D a,const Vector2D b){
  return a.x*b.x+a.y*b.y;
}
LD crossProduct(const Vector2D a, const Vector2D b){return a.x*b.y-a.y*b.x;}
LD angle(Vector2D a,Vector2D b){
  return acos(dotProduct(a,b)/(a.abs()*b.abs()));
}
LD norm(Vector2D a){return a.x*a.x+a.y*a.y;}
Point projection(Point a1,Point a2,Point a3){
  // 点a3にたいする線分a1-a2上への射影をもとめる。
  LD d = dotProduct(a3-a1,a2-a1)/norm(a2-a1);
  return (a1+(a2-a1)*d);
}
Point reflection(Point a1,Point a2,Point a3){
  return (a3+(projection(a1,a2,a3)-a3)*2);
}
int ccw(Point a1,Point a2,Point a3){
  Vector2D a = a2-a1;
  Vector2D b = a3-a1;
  if(crossProduct(a,b) > EPS) return 1; // a1,a2,a3が反時計まわり
  if(crossProduct(a,b) < -EPS) return -1;//a1,a2,a3が時計まわり
  if(dotProduct(a,b) < -EPS) return +2; //a3--a1--a2 で直線
  if(norm(a)< norm(b)) return -2; // a1--a2--a3 の順で直線
  return 0; // a1--a3--a2の順番
}


int main(int argc, char *argv[])
{
  int a[45];
  a[0] = 0;
  a[1] = 1;
  reu(i,2,46){
    a[i] = a[i-1]+a[i-2];
  }
  int t;
  std::cin>>t;
  std::cout<<a[t+1]<<std::endl;

  return 0;
}

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


void fibonacci(int n){
  vector<int> fib;

  fib.push_back(1);
  fib.push_back(1);

  if(n < 2){
    cout << "1" << endl;
  }else if(n == 2){
    fib.push_back(fib.at(0) + fib.at(1));
  }else{
    for(int i = 2;i < n+1;i++){
      fib.push_back(fib.at(i - 2) + fib.at(i - 1));
    }
  }

  cout << fib.back() << endl;

}

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

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384626433832795

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

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

C++: #include <iostream>
#include <stdlib.h>

using namespace std;

int F[44] = {0};

int Fib(int n){

	if(n == 0 || n == 1){
		return (F[n] = 1);
	}

	if(F[n] == 1){
		return F[n];
	}

	return (F[n] = Fib(n-1)+Fib(n-2));
}

int main(){

	int n;

	cin >> n;

	cout << Fib(n) << endl;

	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

C++: #include<iostream>
using namespace std;
int dp[50];
int fibonacci(int x){
  if(x==0 || x==1) return dp[x]=1;
  if(dp[x]!=0) return dp[x];
  return dp[x]=fibonacci(x-1)+fibonacci(x-2);
}
int main(){
  int n;
  cin>>n;
  cout<<fibonacci(n)<<endl;
  return 0;
}

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

using namespace std;

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

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

C++: #include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long ll;
#define MAX_N 100
int d[MAX_N];

void init(){
	rep(i,MAX_N){
		d[i] = -1;
	}
}

int fib(int num){
	if( num == 0) return 1;
	if( num == 1) return 1;
	if(d[num] != -1) return d[num];
	d[num] = fib(num-1) + fib(num-2);
	return d[num];
}


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

C++: #include <stdio.h>
int fib(int);
int fibo[45];
int main(){
  int n,i;
  for(i=0;i<45;i++)fibo[i]=-1;
  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}
int fib(int n){
  if(n==0 || n==1)return fibo[n]=1;
  if(fibo[n]!=-1)return fibo[n];
  return fibo[n]=fib(n-1)+fib(n-2);
}