Go: package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list {
		buf.Write([]byte(fmt.Sprintf(" %d", v)))
	}
	buf.Write([]byte("\n"))
	buf.Flush()
}

//solve
//単純な場合
func fibonacci_(n int) int {
	if n == 0 || n == 1 {
		return 1
	}
	return fibonacci_(n-2) + fibonacci_(n-1)
}

//メモ再帰の利用
func fibonacci(n int) int {
	if n == 0 || n == 1 {
		F[n] = 1
	}
	//F[n]が計算済みの場合
	if F[n] > 0 {
		return F[n]
	}
	F[n] = fibonacci(n-2) + fibonacci(n-1)
	return F[n]
}

const MAX = 50

var F [MAX]int

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	fmt.Println(fibonacci(n))

}

C++: #include "iostream"

using namespace std;

int fib( int n ) {

	if (n == 0 || n == 1) return 1;

	else return fib(n - 1) + fib(n - 2);
}

int main() {


	int n;

	cin >> n;

	cout << fib(n) << endl;

	return 0;
}

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

class Fibonacci{
private:
	int f[45];
	int len;
public:
	Fibonacci(){ f[0] = f[1] = 1; len = 2; }
	int calc(int n);
};

int Fibonacci::calc(int n)
{
	if (n < len) return f[n];
	f[n] = calc(n - 1) + calc(n - 2);
	len++;
	return f[n];
}

int main(void)
{
	Fibonacci fib;
	int n;
	cin >> n;
	cout << fib.calc(n) << endl;
}

C++: #include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
int F[50];
int fib(int i){
	if(i == 0 || i == 1) return 1;

	if(F[i] != -1) return F[i];
	
	return F[i] = fib(i-1) + fib(i-2);
}

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

C++: #include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <climits>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...) do { \
    printf("D(L%d) %s: ", __LINE__, __func__); \
    printf(__VA_ARGS__); \
  } while (false)
#else
#define DPRINTF(...)
#endif // DEBUG

const uint64_t kInvalid = 0;

#if 0
uint64_t calFibonacci(int num, uint64_t *pArray)
{
  if (pArray[num-1] == kInvalid)
    pArray[num-1] = calFibonacci(num-1, pArray);

  if (pArray[num-2] == kInvalid)
    pArray[num-2] = calFibonacci(num-2, pArray);

  return pArray[num-1] + pArray[num-2];
}
#endif


uint64_t calFibonacci(int num, uint64_t *pArray)
{
  assert(num >= 0);

  if (num == 0 | num == 1)
    return 1;

  if (pArray[num] != kInvalid)
    return pArray[num];

  pArray[num] = calFibonacci(num-1, pArray) + calFibonacci(num-2, pArray);
  return pArray[num];
}


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

  DPRINTF("numOfFibonacci %d\n", numOfFibonacci);

  if (numOfFibonacci <= 1)
  {
    cout << "1" << endl;
    return 0;
  }

  uint64_t fibonacci[numOfFibonacci + 1];

  // init
  for (int i = 0; i <= numOfFibonacci; i++)
  {
    fibonacci[i] = kInvalid;
  }

  //fibonacci[0] = 1;
  //fibonacci[1] = 1;

  uint64_t ans = calFibonacci(numOfFibonacci, fibonacci);
  cout << ans << endl;

  return 0;
}

C++: #include <iostream>
using namespace std;
int solution(int n){
    if(n==0) return 1;
    if(n==1) return 1;
    int one=1,two=1,tmp;
    for(int i=1;i<n;i++){
    tmp = two;
    two = two+one;
    one = two;
}
    return two;
}

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

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

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

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

int dp[45];

void init() {
    dp[0] = dp[1] = 1;
    rep(i, 2, 45) {
        dp[i] = dp[i - 1] + dp[i - 2];
    }
}

signed main() {
    int N;
    cin >> N;
    init();
    cout << dp[N] << "\n";
}

C++: #include<iostream>
#include<string>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<deque>
using namespace std;
int memo[44];
int fib(int n)
{
	if (n < 0)return 0;
	if (memo[n] != -1)return memo[n];
	if (n == 0 || n == 1)return 1;
	int ans = 0;
	ans += fib(n - 1) + fib(n - 2);

	return memo[n]=ans;
	
}

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

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

unordered_map<int,int> memo;
int fib(int n){
    if(n<2) return 1;
    if (not memo.count(n)) memo[n] = fib(n-1)+fib(n-2);
    return memo[n];

}

int main(void){cin.tie(0);ios::sync_with_stdio(false);
    int n; cin>>n;
    cout<<fib(n);
}

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 <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  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];
  }
  cout << dp[n] << endl;
}