Skip to content

Commit

Permalink
added fibonacci cpp code
Browse files Browse the repository at this point in the history
  • Loading branch information
DuarteCruz6 authored Dec 10, 2024
1 parent 426bd9e commit 4479bdb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions fibonacci/CPP/fibonacci.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <cstdlib>
#include <cstdio>

int fibonnaci(int n){
if (n==0){
return 0;
}else if(n==1){
return 1;
}

return fibonnaci(n-1) + fibonnaci(n-2);

}

int main(int argc, char* argv[]){
int u = std::atoi(argv[1]);
int sum=0;
for(int i=1;i<u;i++){
sum+=fibonnaci(i);
}
printf("%d\n",sum);
return 0;
}

0 comments on commit 4479bdb

Please sign in to comment.