Algorithm/백준
C++ 알고리즘 - 백준 10870 피보나치 수 5
마루설아
2025. 1. 17. 21:28
https://www.acmicpc.net/problem/10870
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
void CPP_INIT() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int fibo(int n) {
if (n == 0) return 0;
else if (n == 1 || n == 2) return 1;
else return fibo(n - 1) + fibo(n - 2);
}
int main(void) {
CPP_INIT();
int input;
cin >> input;
cout << fibo(input);
}