Closed trizen closed 3 years ago
Thanks! Added to base code as well. E.g. before:
dana@hilbert:~/src/Math-Prime-Util$ make >/dev/null && time mpu '$s+=is_semiprime($_*$_) for 1..1e6; say $s'
78498
real 0m9.086s
user 0m9.062s
sys 0m0.020s
dana@hilbert:~/src/Math-Prime-Util$ make >/dev/null && time mpu '$s+=is_semiprime($_*$_*$_) for 1..1e6; say $s'
0
real 0m42.155s
user 0m41.979s
sys 0m0.078s
After:
dana@hilbert:~/src/Math-Prime-Util$ make >/dev/null && time mpu '$s+=is_semiprime($_*$_) for 1..1e6; say $s'
78498
real 0m0.595s
user 0m0.507s
sys 0m0.004s
dana@hilbert:~/src/Math-Prime-Util$ make >/dev/null && time mpu '$s+=is_semiprime($_*$_*$_) for 1..1e6; say $s'
0
real 0m1.310s
user 0m1.303s
sys 0m0.007s
Currently, the
is_semiprime
function does not check for perfect powers. When given a square of a large prime, the functions takes a very time to determine that the number is indeed a semiprime.