Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- void fibonacci(std::ofstream& plik, const int n) {
- int a{}, b{ 1 }, c{};
- while ((b + c) < n) {
- a = b;
- b = c;
- c = a + b;
- plik << c << std::endl;
- }
- plik.close();
- }
- int main() {
- std::cout << "Podaj liczbe naturalna: ";
- int n;
- std::cin >> n;
- std::ofstream plik{ "fibonacci.txt" };
- fibonacci(plik, n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement