• Source
    1. #include <iostream>
    2. using namespace std;
    3.  
    4. int fibonacci(int x){
    5. //recursion need some base statement to go out of the loop
    6. if(x==1){
    7. return 1;
    8. }
    9. if(x==0){
    10. return 0;
    11. }
    12. return fibonacci(x-2)+fibonacci(x-1);
    13. }
    14.  
    15. int main() {
    16. int n = 8;
    17. //This statement will return the n'th Fibonnaci number
    18. cout<<fibonacci(n);
    19. return 0;
    20. }