Skip to content

Instantly share code, notes, and snippets.

@jepler
Created July 20, 2024 18:54
Show Gist options
  • Save jepler/9908e9ee4a7b0becc11edbedf8b76539 to your computer and use it in GitHub Desktop.
Save jepler/9908e9ee4a7b0becc11edbedf8b76539 to your computer and use it in GitHub Desktop.
#include <gmpxx.h>
#include <charconv>
#include <string>
#include <iomanip>
#include <iostream>
using namespace std;
int main(int argc, char **argv) {
for(int i=1; i<argc; i++) {
size_t ai;
if (std::from_chars(argv[i], argv[i] + strlen(argv[i]), ai).ec == std::errc{}) {
const mpz_class v = mpz_class::fibonacci(ai);
cout << setw(15) << ai << ": "
<< mpz_sizeinbase(v.get_mpz_t(), 2) << " bits, "
// << mpz_sizeinbase(v.get_mpz_t(), 10) << " digits\n"
;
// cout << v << "\n";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment