Skip to content

Instantly share code, notes, and snippets.

@lipx1508
Created January 28, 2023 15:46
Show Gist options
  • Save lipx1508/7d8bb91e628911e8e762d4c0c2ba68ae to your computer and use it in GitHub Desktop.
Save lipx1508/7d8bb91e628911e8e762d4c0c2ba68ae to your computer and use it in GitHub Desktop.
Really basic implementation of Fibonacci's formula in C++, please don't blame me if something is written badly. I'm not a GREAT programmer tho.
// Basic implementation of Fibonacci's sequence in C++.
#include <iostream>
int main(int argc, char * argv[]) {
unsigned int x, y, z, n;
std::cout << "Number of iterations: ";
std::cin >> n;
for (unsigned int i = 0; i < n; i++) {
z = x + y, x = y, y = z;
std::cout << z << '\n';
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment