Print amount of steps at the end
This commit is contained in:
parent
9e21df19cd
commit
6fb0e7acd9
5
main.cpp
5
main.cpp
@ -29,12 +29,15 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
mpz_t x; // mpz_t is the GMP equiv. of int
|
||||
mpz_t xmod2; // Store x % 2
|
||||
mpz_t steps; // Steps taken to get to one
|
||||
// Init vars (if not disabled init)
|
||||
#ifndef GMPLESS
|
||||
mpz_init_set_str(x, argv[1],10);
|
||||
mpz_init(xmod2);
|
||||
mpz_init(steps);
|
||||
#else
|
||||
x = std::stoll(argv[1]);
|
||||
steps = 0;
|
||||
#endif
|
||||
// Output x
|
||||
std::cout << x << '\n'; // impacted section of code
|
||||
@ -47,6 +50,8 @@ int main(int argc, char* argv[]) {
|
||||
mpz_mul_ui(x,x,3); // x *= 3
|
||||
mpz_add_ui(x,x,1); // x += 1
|
||||
}
|
||||
mpz_add_ui(steps,steps,1); // steps += 1
|
||||
std::cout << x << '\n';
|
||||
}
|
||||
std::cout << "Steps: " << steps << '\n';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user