Calmo numbers: Difference between revisions

Added Perl
(add RPL)
(Added Perl)
Line 651:
{{out}}
<pre> 165 273 385 399 561 595 665 715 957
</pre>
 
=={{header|Perl}}==
{{libheader|ntheory}}
<syntaxhighlight lang="perl" line>
use v5.36;
use ntheory<is_prime divisors>;
use List::Util 'all';
use experimental 'for_list';
 
sub c_divisors ($n) { my @d = divisors $n; pop @d; shift @d; @d }
 
for (2..1000) {
my @d = c_divisors $_;
next unless @d and 0 == @d%3;
my @sums;
for my($a,$b,$c) (@d) { push @sums, $a+$b+$c }
print "$_ " if all { is_prime $_ } @sums;
}
say '';
</syntaxhighlight>
{{out}}
<pre>
165 273 385 399 561 595 665 715 957
</pre>
 
2,392

edits