#include /* #include */ #include int main() { mpz_t n, st, j, g, k; mpz_init(n); mpz_init(st); mpz_init(j); mpz_init(g); mpz_init(k); printf("Enter startoff in base ten: "); mpz_inp_str(st, stdin, 10); if (mpz_cmp_ui(st, 3) < 0) { mpz_set_ui(st, 3); printf("2 "); } mpz_mod_ui(k, st, 2); if (mpz_sgn(k) == 0) mpz_sub_ui(n, st, 1); else mpz_sub_ui(n, st, 2); /* make sure n is odd */ do { mpz_add_ui(n, n, 2); /* n += 2; */ mpz_sqrt(g, n); /* g = sqrt(n); */ /* mpz_out_str(stdout, 10, n); printf(" "); * mpz_out_str(stdout, 10, g); printf(" "); */ mpz_set_ui(j, 3); /* j = 3; */ mpz_mod(k, n, j); /* check if n is divisible by j */ /* mpz_out_str(stdout, 10, j); printf(" "); * mpz_out_str(stdout, 10, k); printf("\n"); */ while ((mpz_sgn(k) != 0) && (mpz_cmp(j, g) <= 0)) { mpz_add_ui(j, j, 2); mpz_mod(k, n, j); } if (mpz_cmp(j, g) > 0) { mpz_out_str(stdout, 10, n); printf(" "); } } while (1); }