mirror of
https://github.com/lucaspalomodevelop/cpp_stuff.git
synced 2026-03-12 22:47:22 +00:00
add fibonacci
This commit is contained in:
parent
1de13ffb1d
commit
be69eb0f29
@ -26,7 +26,7 @@ void readfile(string file)
|
|||||||
cout << line << '\n';
|
cout << line << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
myfile.close();
|
myfile.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,5 @@
|
|||||||
|
Hallo Welt!
|
||||||
|
Hallo Welt!
|
||||||
|
Hallo Welt!
|
||||||
|
Hallo Welt!
|
||||||
|
Hallo Welt!
|
||||||
BIN
fibonacci/fib
Executable file
BIN
fibonacci/fib
Executable file
Binary file not shown.
14
fibonacci/main.cpp
Normal file
14
fibonacci/main.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include<iostream>
|
||||||
|
|
||||||
|
int fib(int n)
|
||||||
|
{
|
||||||
|
return n < 2 ? 1 : fib(n-2)+ fib(n-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << "Geben sie an die wievielte fib. Zahl sie suchen: ";
|
||||||
|
int n = 0;
|
||||||
|
std::cin >> n;
|
||||||
|
std::cout << "fib(" << n << ") = " << fib(n) << "\n";
|
||||||
|
}
|
||||||
5
fibonacci/makefile
Normal file
5
fibonacci/makefile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
dev: compile run
|
||||||
|
compile:
|
||||||
|
g++ -o fib main.cpp
|
||||||
|
run:
|
||||||
|
./fib
|
||||||
Loading…
x
Reference in New Issue
Block a user