Skip to content

Instantly share code, notes, and snippets.

@parsa
Created November 16, 2022 17:45
Show Gist options
  • Save parsa/d7f4d55e6f88fc8ed1577421dc6f7d64 to your computer and use it in GitHub Desktop.
Save parsa/d7f4d55e6f88fc8ed1577421dc6f7d64 to your computer and use it in GitHub Desktop.
Fibonacci using boost::multiprecision::cpp_int
#include <boost/multiprecision/cpp_int.hpp>
#include <iostream>
int main() {
boost::multiprecision::cpp_int n1 = 0, n2 = 1;
for (long i = 1; i <= 1000000; ++i) {
n1 = std::exchange(n2, n1 + n2);
}
std::cout << n2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment