Square-free integers: Difference between revisions
Content added Content deleted
(added FreeBASIC) |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Minor tweaks.) |
||
Line 690:
=={{header|Perl 6}}==
{{works with|Rakudo|2018.06}}
The prime factoring algorithm is not really the best option for finding long runs of sequential square-free numbers. It works, but is probably better suited for testing arbitrary numbers rather than testing every sequential number from 1 to some limit. If you know that that is going to be your use case, there are faster algorithms
<lang perl6># Prime factorization routines
Line 701:
sub find-factor ( Int $n, $constant = 1 ) {
return 2 unless $n +& 1;
if (my $gcd = $n gcd 6541380665835015) > 1 {
return $gcd if $gcd != $n
}
my $x = 2;
my $rho = 1;
Line 718 ⟶ 722:
# Task routine
# The Task
|