Created
November 7, 2024 20:15
-
-
Save jamesy0ung/6d018ad2bf28278faae1e21a4ff0053d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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