Ruth-Aaron numbers: Difference between revisions

Content added Content deleted
(→‎{{header|Wren}}: Cut out duplicated calculations.)
Line 34: Line 34:





=={{header|Perl}}==
<lang perl>#!/usr/bin/perl

use strict;
use warnings;
use ntheory qw( factor vecsum );
use List::AllUtils qw( uniq );

#use Data::Dump 'dd'; dd factor(6); exit;

my $n = 1;
my @answers;
while( @answers < 30 )
{
vecsum(factor($n)) == vecsum(factor($n+1)) and push @answers, $n;
$n++;
}
print "factors:\n\n@answers\n\n" =~ s/.{60}\K /\n/gr;

$n = 1;
@answers = ();
while( @answers < 30 )
{
vecsum(uniq factor($n)) == vecsum(uniq factor($n+1)) and push @answers, $n;
$n++;
}
print "divisors:\n\n@answers\n" =~ s/.{60}\K /\n/gr;</lang>
{{out}}
<pre>
factors:

5 8 15 77 125 714 948 1330 1520 1862 2491 3248 4185 4191 5405
5560 5959 6867 8280 8463 10647 12351 14587 16932 17080 18490
20450 24895 26642 26649

divisors:

5 24 49 77 104 153 369 492 714 1682 2107 2299 2600 2783 5405
6556 6811 8855 9800 12726 13775 18655 21183 24024 24432 24880
25839 26642 35456 40081
</pre>


=={{header|Phix}}==
=={{header|Phix}}==