Factorize denominator of rationale
Øystein Schønning-Johansen
oysteijo at gmail.com
Tue Nov 22 11:00:50 CET 2022
Hi!
I'm working with probabilities of a sequence of dice rolls, and the
different probabilities to be exact with rationales. I've got it all
working fine.
However, I want to write out all probabilities to a file and since there's
a lot of them, I want to reduce the file size and need the output string to
be as short as possible. I hence use mpq_canonicalize() and write out with
base 36. Works, but can I even be better?
Since these are consecutive dice rolls, I can always represent the
denominator (after canonicalize) as (2^a)*(3^b) and I then only have to
store the a and the b. So, the question is: How can I find the a and the b
of such denominators?
Best regards,
-Øystein
More information about the gmp-discuss
mailing list