Go: package main

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

// func fib(n int) int{
// 	if n == 0 || n == 1{
// 		return 1
// 	} else {
// 		return fib(n-1) + fib(n-2)
// 	}
// }

// func main(){
// 	sc := bufio.NewScanner(os.Stdin)
// 	sc.Scan()
// 	n, _ := strconv.Atoi(sc.Text())
// 	fmt.Println(fib(n))
// }

import (
	"fmt"
)

func main(){
	var n, pre1, pre2, now int
	fmt.Scan(&n)
	if n == 0 || n == 1{
		fmt.Println(1)
	} else {
		pre1, pre2 = 1, 1
		for i:=1; i<n; i++{
			now = pre1 + pre2
			pre2 = pre1
			pre1 = now
		}
		fmt.Println(now)
	}

}

C++: #include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
} 

ll fibonacci(int x){
	if(x<=1)return 1;
	static vector<ll> memo(45, -1);
	if(memo[x]>=0)return memo[x];
	return memo[x] = fibonacci(x-1) + fibonacci(x-2);
}

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

C++: #include <iostream>
#include<algorithm>
#include<stack>
#include<string>
#include<cstdlib>
#include<stdio.h>
using namespace std;
int n,a[50];
int solve(int i){
    if(i==1||i==0)return 1;
    return solve(i-1)+solve(i-2);
}
int main(){
    int n;
    cin>>n;
    cout<<solve(n)<<endl;
    return 0;
}

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

template <typename T>
class Matrix
{
public:
    Matrix(int n, int m)
        : m_value(n, vector<T>(m, 0)), m_row(n), m_col(m) {}
    Matrix(initializer_list<initializer_list<T>> init)
        : m_value(init.begin(), init.end()), m_row(init.size()), m_col((*init.begin()).size()) {}

    int row(void) const { return m_row; }
    int col(void) const { return m_col; }

    vector<T> &operator[](int i) { return m_value[i]; }
    const vector<T> &operator[](int i) const { return m_value[i]; }

    // 単位行列E
    static Matrix E(int n)
    {
        Matrix res(n, n);
        for (int i = 0; i < n; i++) res[i][i] = 1;
        return res;
    }

    Matrix &operator+=(const Matrix &A)
    {
        int n = this->row(), m = this->col();
        assert(n == A.row() && m == A.col());

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                (*this)[i][j] += A[i][j];
            }
        } 
        return *this;
    }

    Matrix &operator-=(const Matrix &A)
    {
        int n = this->row(), m = this->col();
        assert(n == A.row() && m == A.col());

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                (*this)[i][j] -= A[i][j];
            }
        } 
        return *this;
    }

    Matrix &operator*=(const Matrix &A)
    {
        int n = this->row(), m = this->col(), l = A.col();
        assert(m == A.row());

        Matrix res(n, l);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                for (int k = 0; k < m; k++) {
                    res[i][j] += (*this)[i][k] * A[k][j];
                }
            }
        }
        return *this = move(res);
    }

    Matrix operator+(const Matrix &A) const { return Matrix(*this) += A; }
    Matrix operator-(const Matrix &A) const { return Matrix(*this) -= A; }
    Matrix operator*(const Matrix &A) const { return Matrix(*this) *= A; }

    Matrix pow(ll n) const
    {
        Matrix e = *this, res = E(this->row());
        while (n) {
            if (n & 1) res *= e;
            e *= e;
            n >>= 1;
        }
        return res;
    }

    friend ostream &operator<<(ostream &os, const Matrix &A)
    {
        int n = A.row(), m = A.col();
        for (int i = 0; i < n; i++) {
            os << "[";
            for (int j = 0; j < m; j++) {
                os << A[i][j];
                if (j < m - 1) os << ", ";
            }
            os << "]";
            if (i < n - 1) os << endl;
        }
        return os;
    }

private:
    vector<vector<T>> m_value;
    size_t m_row;
    size_t m_col;
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    Matrix<ll> A = {{1, 1}, {1, 0}};
    A = A.pow(n);
    cout << A[1][0] + A[1][1] << endl;
    return 0;
}

C++: 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);

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < n; i++)
typedef long long ll;
// Welcome to my source code!

int F[45] = {};

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

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

C++: // -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_10_A: Fibonacci Number

#include <algorithm>
#include <cstdio>

#define NDEBUG
#include <cassert>

class Fibonnacci {
  static const unsigned int N = 44u;
  unsigned int n_;
  unsigned long* f_;

public:
  Fibonnacci(unsigned int n = N) : n_(std::max(1u, n))
  {
    f_ = new unsigned long[n_+1];
    f_[0] = f_[1] = 1;
    for (auto i = 2u; i <= n_; ++i) {
      f_[i] = f_[i-1] + f_[i-2];
    }
  }

  ~Fibonnacci() { delete[] f_; }
  
  unsigned long operator () (unsigned int n) const
  {
    assert(n <= n_);
    return f_[n];
  }
};

int main()
{
  unsigned int n;
  std::scanf("%u", &n);
  Fibonnacci fib;
  std::printf("%lu\n", fib(n));
}

// eof

C++: #include <cstdint>

using namespace std;

#define MEMO_SIZE 45
int64_t memo[MEMO_SIZE];

void fib_init()
{
  for (uint32_t i = 0; i < MEMO_SIZE; i++) {
    memo[i] = -1;
  }
}

uint32_t fib(uint32_t i)
{
  if (i == 0) {
    return memo[0] = 1;
  } else if (i == 1) {
    return memo[1] = 1;
  } else {
    if (memo[i] != -1)
      return memo[i];
    else {
      return memo[i] = fib(i - 1) + fib(i - 2);
    }
  }
}

#include <iostream>

int32_t main()
{
  fib_init();
  uint32_t i;
  cin >> i;
  cout << fib(i) << endl;
  return 0;
}

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

unordered_map<int,int> memo;
constexpr 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 <bits/stdc++.h>
using namespace std;

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