Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
15
Task/Additive-primes/Perl/additive-primes.pl
Normal file
15
Task/Additive-primes/Perl/additive-primes.pl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use ntheory 'is_prime';
|
||||
use List::Util <sum max>;
|
||||
|
||||
sub pp {
|
||||
my $format = ('%' . (my $cw = 1+length max @_) . 'd') x @_;
|
||||
my $width = ".{@{[$cw * int 60/$cw]}}";
|
||||
(sprintf($format, @_)) =~ s/($width)/$1\n/gr;
|
||||
}
|
||||
|
||||
my($limit, @ap) = 500;
|
||||
is_prime($_) and is_prime(sum(split '',$_)) and push @ap, $_ for 1..$limit;
|
||||
|
||||
print @ap . " additive primes < $limit:\n" . pp(@ap);
|
||||
Loading…
Add table
Add a link
Reference in a new issue