in reply to Re^2: Prime Number Finder
in thread Prime Number Finder

Can you please explain you code? I'm a noob, honestly i didn't understand your code but it works fine.

Replies are listed 'Best First'.
Re^4: Prime Number Finder
by Anonymous Monk on Jul 02, 2023 at 13:43 UTC

    Managed utilize it, but I kinda butchered it. Yeah you can still use Math::Prime::Util.

    But I do not know how exactly it work. It does some magic with the output line separator.

    That if structure is hideous.

    sub primes($end) { open my $FH, '>', \my $output or die "Cannot open filehandle: $!"; $output = ""; $\ = 1; while($\ < $end) { $_ = ""; print $FH $_."\n" if( (1 x++ $\) !~ m/ {$ | ^(..+)\ +1+$ | ^\\\$\\$ }/x ); } close($FH); my @primeNumbers = split("\n", $output); shift @primeNumbers; # a blank element will get through return \@primeNumbers; }