Compare commits

..

No commits in common. "master" and "1.0-nongmp" have entirely different histories.

2 changed files with 0 additions and 8 deletions

View File

@ -7,9 +7,6 @@ To build:
- With GMP: Run `make -j1` (any more than `-j1` doesn't really do anything, there's four things to do and they can't be put out of order).
- Without GMP: Run `make gmpless -j1` (see above parenthetical statement).
You can get releases at [here](https://git.sdf.org/ilikecats/collatz/releases), but only GMP releases (except for 1.0), and only for GNU/Linux (except for 1.0).
You have to build without GMP if you don't want to/can't use GMP.
Algorithm:
- Start with number.
- If number is even, divide by two.

View File

@ -29,15 +29,12 @@ 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
@ -50,8 +47,6 @@ 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';
}