Skip to content

Instantly share code, notes, and snippets.

@XerxesZorgon
Created December 30, 2020 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save XerxesZorgon/27bec0167801a19d8ed24542c30672ad to your computer and use it in GitHub Desktop.
Save XerxesZorgon/27bec0167801a19d8ed24542c30672ad to your computer and use it in GitHub Desktop.
Returns the cardinality of the multiplicative partition set for an integer (in PARI/GP)
/*
Returns the number of multiplicative partitions of integer n
Ref: https://oeis.org/A001055
https://oeis.org/A162247
https://oeis.org/A162247/a162247.txt
Inputs:
n: Non-negative integer
m: Maximum factor (optional)
Output:
V: Vector of multiplicative partitions of n
Example:
mnumbpart(60) = 11
Written by: John Peach 29-Dec-2020
Modified from fcnt function by Michael B. Porter (Oct 29 2009), https://oeis.org/A001055
*/
mnumbpart(n,m = n) =
{
local(s);
s=0;
if(n==1,s=1,
fordiv(n,d,if(d>1&d<=m,s=s+mnumbpart(n/d,d)))
);
return(s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment