Is there a link to a description of Max Alekseyev's algorithm somewhere? I can attempt to reverse-engineer it from the code, but a description would be better.
Browsing the code I see that the PP code does an unnecessary (and costly) grep to free memory, I suggest:
- delete @r{ grep { $_ != $n } keys %r }; # Delete all intermediate results
- return Mvecsort($r{$n});
+ my $rn = $r{$n}; %r = (); # Delete all intermediate results
+ return Mvecsort($rn);
The C code has this early assert:
MPUassert(n <= UV_MAX/7.5, "inverse_totient_list n too large");
.. which seems a shame - the Perl code has no such restriction. I guess the issue is that some results in the list can exceed UV_MAX in this case - the assert message is not very clear about that. (53# > 2^64, \prod_{p in P, p < 53}{p/(p-1)} ~= 7.21)
Is there a link to a description of Max Alekseyev's algorithm somewhere? I can attempt to reverse-engineer it from the code, but a description would be better.
Browsing the code I see that the PP code does an unnecessary (and costly) grep to free memory, I suggest:
The C code has this early assert:
.. which seems a shame - the Perl code has no such restriction. I guess the issue is that some results in the list can exceed UV_MAX in this case - the assert message is not very clear about that. (53# > 2^64, \prod_{p in P, p < 53}{p/(p-1)} ~= 7.21)