Skip to content
Snippets Groups Projects
Commit b68100b1 authored by MATyufyakov's avatar MATyufyakov
Browse files

1234567

parent dc7e1ec9
No related branches found
No related tags found
No related merge requests found
*.exe
.vscode
\ No newline at end of file
a.exe 0 → 100644
File added
File added
main.cpp 0 → 100644
/* числа фиббоначи
нужен n-ый символ ряда фиббоначи
на фходе число n
должна вывести число
g++ main.cpp -o fibbonaci
./fibbonaci.exe 5
*/
#include<iostream>
long long unsigned fibbonaci(int n){
if (n==1 || n==2){
return 1;
}
long long unsigned result_1=1;
long long unsigned result_2=1;
long long unsigned result_3=0;
for (int i=3; i<=n ; i++){
result_2=result_1+result_2;
result_1=result_2-result_1;
}
return result_2;
return fibbonaci(n-1)+fibbonaci(n-2);
}
int main(int argc, char* argv[]){
if (argc !=2){
std::cout <<"incorrect usage" << std::endl;
return 1;
}
int n = atoi(argv[1]);
if (n<1){
std::cout << "Use a number > 0" << std::endl;
return 2;
}
if (n > 93){
std::cout << "Number so BIG" << std::endl;
return 3;
}
for (int i=1; i<=n; i++){
std::cout << "number" << i << ": "<< fibbonaci(i)<<std::endl;
}
std::cout << fibbonaci(n) << std::endl;
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment