Go: package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	dp := make([]int, N+1)
	dp[0] = 1
	dp[1] = 1
	for i := 2; i <= N; i++ {
		dp[i] = dp[i-1] + dp[i-2]
	}

	fmt.Fprintln(wtr, dp[N])
	wtr.Flush()
}

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

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

  cout << f[n] << endl;
  return 0;
}

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