Closed trizen closed 4 years ago
Great idea.
I need to get the current code released, especially the GMP code. It's been way too long between pushes to CPAN.
I added is_almost_prime(n,k) as a start, to the native int code. It needs optimized PP and some GMP code.
I just added almost_prime_count(n,k) which seems reasonably efficient. I'm testing an nth_almost_prime(n,k) which just reverses using the count, so not the most efficient but looks handy. Some of the OEIS sequences end at 10^14 which this should be able to add a couple terms to. After more testing.
If you have any good results on upper bounds, or better ways to get the nth value that would be great. I haven't found anything obvious.
I still have to do bigint coding.
It would be nice to have a new method, called
almost_prime_count(n,k)
, which counts the number of k-almost primes <= n.Algorithm in Perl:
Note:
See also: https://en.wikipedia.org/wiki/Almost_prime