Created
July 20, 2024 20:51
-
-
Save jepler/f6296a5a63a82446f8146e0a74cdbe7b to your computer and use it in GitHub Desktop.
This file contains hidden or 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(), 10) << " digits," | |
<< mpz_sizeinbase(v.get_mpz_t(), 2) << " bits\n" | |
; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment