Skip to content
Snippets Groups Projects
Commit 979a2d7b authored by Jake Feddersen's avatar Jake Feddersen
Browse files

Notes

parent 2b062ed7
No related branches found
No related tags found
No related merge requests found
File added
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
int main(int argc, char *argv[]) {
int i;
mpz_t val;
mpz_t op1;
mpz_t op2;
mpz_init(val);
mpz_init(op1);
mpz_init(op2);
gmp_sscanf(argv[1], "%Zd", val);
mpz_set_ui(op2, 1);
if (mpz_cmp_ui(val, 1)) {
for (i = 1; mpz_cmp_ui(val, 1); i++) {
mpz_and(op1, val, op2);
if (mpz_get_ui(op1)) {
//odd
mpz_mul_ui(val, val, 3);
mpz_add_ui(val, val, 1);
} else {
// even
mpz_tdiv_q_ui(val, val, 2);
}
}
printf("%d\n", i-1);
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment