Karim Belabas on Thu, 28 Aug 2025 21:53:22 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: PARI/GP wrong on 7!!+7+1 being not prime, or oeis.org/Mathematica?


* Bill Allombert [2025-08-28 19:59]:
> On Thu, Aug 28, 2025 at 05:02:28PM +0200, hermann@stamm-wilbrandt.de wrote:
> > @Bill, you once added primorial operator after first stating "not needed".
> > 
> > $ gp -q
> > ? version
> > [2, 16, 1]
> > ? 7#
> > 210
> > ?
> > 
> > Are you in the mood of adding another operator (!!) to GP?
> 
> Adding this one would break backward compatibility, so this is not
> an option.
> 
> ? 3!!
> %1 = 720

A generic solution:

? double_factorial(n) = vecprod(vector(n \ 2, i, n-2*i+2));
? double_factorial(9)
%1 = 945
? double_factorial(10)
%2 = 3840

N.B. The special case "n even" is trivial:

? double_factorial_even(n) = (n/2)! << (n/2);
? double_factorial_even(10) 
%3 = 3840

? A = double_factorial_even(10^7);
time = 1,672 ms.
? B = double_factorial(10^7);
time = 3,000 ms.
? A == B
%6 = 1

Cheers,

    K.B.
-- 
Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/