Bill Allombert on Sat, 18 Apr 2026 12:18:54 +0200


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

Re: numbpart(n, {a = k})


On Fri, Apr 17, 2026 at 04:50:05PM +0200, Ruud H.G. van Tol wrote:
> 
> On 2026-04-17 12:03, Bill Allombert wrote:
> > On Fri, Apr 17, 2026 at 08:55:23AM +0200, Ruud H.G. van Tol wrote:
> > > Would a variant numbpart(n, {a = k}) be interesting, like Maple has?
> > > With the optional a-parameter like with partitions(k, {a = k}, {n = k}).
> > numbpart use Rademacher formula, which is much faster than #partitions(n) but is
> > only valid for partitions(n,,).
> > I do not know fast formula for the other cases.
> > 
> > For example pari can compute numbpart(1000000) in 5 ms
> 
> I presumed that it would become an additional GEN numbpart_GG(GEN n, GEN a).

You can write it in GP in one line:

nbpart(k,a=k,n=k)=my(s=0);forpart(x=k,s++,a,n);s;

Cheers,
Bill