Go: // AOJ ALDS1_10_A: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_A

package main

import (
	"fmt"
)

func fibonacci(n int) int64 {
	f := []int64{1, 1}
	for i := 2; i <= n; i++ {
		f = append(f, f[i-2] + f[i-1])
	}
	return f[n]
}

func main() {
	var n int
	fmt.Scanf("%d", &n)
	fmt.Println(fibonacci(n))
}

C++: #include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1};

int a = 0, b = 1;

void fib(int n) {
	int ans = 1;
	for (int i = 0; i < n && n >= 2; ++i) {
		ans = a + b;
		a = b;
		b = ans;
	}
	cout << ans << endl;
}

int main() {
	int n; cin >> n;
	fib(n);
	return 0;
}

C++: // フィボナッチ数列
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 44
// 無効な値の定義
const int INV = -1;

// フィボナッチ数列を保持する配列
int fib[MAX_N + 1];

int Fibonacci(int n);

int main(void)
{

    int n;

    cin >> n;

    for(int i = 0; i < MAX_N + 1; i++)
    {
        fib[i] = INV;
    }

    fib[0] = 1;
    fib[1] = 1;

    // フィボナッチ数列の表示
    printf("%d\n", Fibonacci(n));

    return 0;
}

// フィボナッチ数列を算出する関数
int Fibonacci(int n)
{

    if( n <= 1)
    {
        // n = 0, n = 1 の時
        return 1;
    }

    if( fib[n] != INV )
    {
        // 既に計算されている時は, 結果を返す
        return fib[n];
    }

    // フィボナッチ数列の算出の算出
    fib[n] = Fibonacci(n - 1) + Fibonacci(n - 2);

    return fib[n];
}

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

int S[50];

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

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

int main(int argc, char const *argv[])
{
  int n; cin >> n ;
  int F[50];
  F[0] = F[1] = 0;
  for (int i = 2 ; i < n; ++i)
  {
    F[i] = F[i-1] + F[i- 2];
  }

  cout << F[n] << endl;

  return 0;
}

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

int fib(int n)
{
	int f[45];
	if(n==0 || n==1) return f[n]=1;
	if(f[n]>0) 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++: #include <bits/stdc++.h>
using namespace std;

int fibonacci(int n, vector<int> &memo) {
  if (n == 0 || n == 1) return 1;
  if (memo[n] != -1) return memo[n];
  return memo[n] = fibonacci(n - 1, memo) + fibonacci(n - 2, memo);
}

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

  vector<int> memo(50, -1);
  cout << fibonacci(N, memo) << endl;
}

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

int main(){
  int n;
  cin >> n;
  int fn[50];
  fn[0] = fn[1] = 1;
  for(int i = 2; i <= n; i++) fn[i] = fn[i - 1] + fn[i - 2];

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

C++: #pragma GCC diagnostic ignored "-Wunused-variable" 
#include <bits/stdc++.h>
using namespace std;

//#define BOOST
#ifdef BOOST
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/range/adaptor/reversed.hpp>
using namespace boost;
using ml = boost::multiprecision::cpp_int;
using md = boost::multiprecision::cpp_dec_float_100;
#define forir(i, ...) if(ll i=(ll)v.size())for(__VA_ARGS__)if(i--,1)
#define eachr(i, e, c) forir(i, auto &&e: adaptors::reverse(c))
#endif

/***** type *****/
using ll = long long;
using ld = long double;
using pll = pair<long long, long long>;
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
template <class T> using vvvt = vector<vector<vector<T>>>;
/***** define *****/
#define all(c) (c).begin(), (c).end()            // begin to end
#define coutd cout << fixed << setprecision(10)  // cout double
#define output(x) do{cout<<x;return 0;}while(0)  // cout return
#define rep(i, b, e) for (ll i = b; i < e; i++)  // repeat
#define repr(i, b, e) for (ll i = b; e < i; i--) // repeat reverse
#define fori(i, ...) if (ll i = -1) for(__VA_ARGS__) if (i++, 1)
#define each(i, e, c) fori (i, auto&& e: c)      // for each
/***** const value *****/
#define llong_max 9223372036854775807            // 9 * 10^18
#define ldbl_max 1.79769e+308                    // 1.7 * 10^308
#define pi 3.1415926535897932                    // 3.14 ...
/***** lambda *****/
auto Ceil = [] // if (a % b != 0) return a / b + 1;
(auto x) { return (ll)ceil(x); };
auto Count = [] // long long count value
(auto b, auto e, auto x) { return (ll)count(b, e, x); };
auto CtoL = [] // char to number
(auto c) { return (ll)c - (ll)'0'; };
auto LtoC = [] // number to char
(auto n) { return (char)('0' + n); };
auto Pow = [] // long long pow
(auto a, auto b) { return (ll)pow(a, b); };
auto Pow2 = [] // long long pow2
(auto n) { return (1LL << n); };
auto Pow10 = [] // long long pow10
(auto n) { return (ll)pow(10, n); };
auto Size = []  // long long collection size
(auto& c) { return (ll)(c).size(); };
auto Sum = [] // long long accumulate
(auto b, auto e) { return accumulate(b, e, 0LL); };

/***** template *****/
template <class T> void MakeVVT
(ll ys, ll xs, vvt<T>& v, T fill = T())
{	// vector<vector<T>> resize + fill
	v.resize(ys); rep(y, 0, ys) v[y].resize(xs, fill);
}
template <class T> void MakeVVVT
(ll zs, ll ys, ll xs, vvvt<T>& v, T fill = T())
{	// vector<vector<vector<T>>> resize + fill
	v.resize(zs); rep(z, 0, zs) MakeVVT(ys, xs, v[z], fill);
}
template <class T> void InputVT
(ll xs, vt<T>& v, T fix = T())
{	// input vector<T> (T != struct) + fix
	v.resize(xs); rep(i, 0, xs) { cin >> v[i]; v[i] += fix; }
}
template <class T> void InputVVT
(ll ys, ll xs, vvt<T>& v, T fix = T())
{	// input vector<vector<T>> (T != struct) + fix
	MakeVVT(ys, xs, v, fix);
	rep(y, 0, ys) rep(x, 0, xs) { cin >> v[y][x]; v[y][x] += fix; }
}
template <class T> void InputVVVT
(ll zs, ll ys, ll xs, vvvt<T>& v, T fix = T())
{	// input vector<vector<vector<T>>> (T != struct) + fix
	v.resize(zs); rep(z, 0, zs) InputVVT(ys, xs, v[z], fix);
}

/**************************************/
/********** BEGIN OF NYA LIB **********/
/**************************************/

namespace NyaGadget {}

/**************************************/
/*********** END OF NYA LIB ***********/
/**************************************/

using namespace NyaGadget;
//using mll = NT_ModLL< 1000000007 >;
//using mll = NT_ModLL< 998244353 >;

int main(void)
{
	ll n; cin >> n;
	vt<ll> dp(n+1, 1);
	rep(i, 2, n + 1) dp[i] = dp[i - 1] + dp[i - 2];
	cout << dp[n] << endl;
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 44;
int n;
ll dp[N+1];

ll fib(int n) {
  if (n <= 1) return 1LL;
  return dp[n]>0 ? dp[n] : dp[n] = fib(n-1) + fib(n-2);
}

int main() {
  memset(dp, 0, sizeof(dp));
  scanf("%d ", &n);
  printf("%lld\n", fib(n));
  return 0;
}

C++: #include <iostream>

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

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

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