Skip to content

Instantly share code, notes, and snippets.

@jamesy0ung
Created November 7, 2024 20:15
Show Gist options
  • Save jamesy0ung/6d018ad2bf28278faae1e21a4ff0053d to your computer and use it in GitHub Desktop.
Save jamesy0ung/6d018ad2bf28278faae1e21a4ff0053d to your computer and use it in GitHub Desktop.
#include <iostream>
#include <climits>
long long int f0 = { 0 };
long long int f1 = { 1 };
long long int fn = {};
int main()
{
std::cout << "Printing fibbonacci sequence\n";
while (true) {
if (f0 > LLONG_MAX - f1)
{
std::cout << "Reached maximum value able to be stored by long long: " << f0 << std::endl;
break;
};
fn = f0 + f1;
f0 = f1;
f1 = fn;
std::cout << fn << std::endl;
};
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment