mirror of
https://github.com/supleed2/ELEC40006-P1-CW.git
synced 2024-11-10 02:05:48 +00:00
24 lines
280 B
C++
24 lines
280 B
C++
|
#include <iostream>
|
||
|
using namespace std;
|
||
|
|
||
|
/*
|
||
|
Takes one input via stdin, the integer n
|
||
|
*/
|
||
|
|
||
|
int fib(const int n){
|
||
|
int y;
|
||
|
if (n <= 1) {
|
||
|
y = 1;
|
||
|
}else {
|
||
|
y = fib(n-1);
|
||
|
y = y + fib(n-2);
|
||
|
}
|
||
|
return y;
|
||
|
}
|
||
|
|
||
|
int main(){
|
||
|
int n;
|
||
|
cin >> n;
|
||
|
cout << fib(n) << endl;
|
||
|
}
|