X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/9bfacb4f6d5be052968fa1e312f00e3af3bd9fdb..0e1199ac5a1d8410608d488aaa787fb207fc3746:/math/pgen-granfrob.c?ds=sidebyside diff --git a/math/pgen-granfrob.c b/math/pgen-granfrob.c index 98c8f8cb..05165393 100644 --- a/math/pgen-granfrob.c +++ b/math/pgen-granfrob.c @@ -36,16 +36,6 @@ /*----- Main code ---------------------------------------------------------*/ -static int squarep(mp *n) -{ - mp *t = MP_NEW; - int rc; - - if (MP_NEGP(n)) return (0); - t = mp_sqrt(t, n); t = mp_sqr(t, t); - rc = MP_EQ(t, n); mp_drop(t); return (rc); -} - /* --- @pgen_granfrob@ --- * * * Arguments: @mp *n@ = an integer to test @@ -103,7 +93,7 @@ int pgen_granfrob(mp *n, int a, int b) e = mp_jacobi(&md, n); /* If %$\Delta$% is a perfect square then the test can't work. */ - if (e == 1 && squarep(&md)) { rc = PGEN_ABORT; goto end; } + if (e == 1 && mp_squarep(&md)) { rc = PGEN_ABORT; goto end; } } else { /* Determine parameters. Use Selfridge's `Method A': choose the first * %$\Delta$% from the sequence %$5$%, %$-7$%, %%\dots%%, such that @@ -113,7 +103,7 @@ int pgen_granfrob(mp *n, int a, int b) wa = 1; wd = 5; for (;;) { e = mp_jacobi(&md, n); if (e != +1) break; - if (wd == 25 && squarep(n)) { rc = PGEN_FAIL; goto end; } + if (wd == 25 && mp_squarep(n)) { rc = PGEN_FAIL; goto end; } wd += 2; md.f ^= MP_NEG; } a = 1; d = wd;