Created
July 20, 2024 18:54
-
-
Save jepler/9908e9ee4a7b0becc11edbedf8b76539 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 <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