Skip to content

Commit

Permalink
Merge pull request bddicken#230 from DuarteCruz6/cpp_fibonacci
Browse files Browse the repository at this point in the history
added fibonacci cpp code
  • Loading branch information
bddicken authored Dec 11, 2024
2 parents 50562e9 + 4479bdb commit 34c6d12
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 34c6d12

Please sign in to comment.