aboutsummaryrefslogtreecommitdiff
path: root/challenge-169/james-smith/perl/ch-2-npp.pl
blob: 590e01532570fdf196f6691c0c444d6dfe9d9ca5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/local/bin/perl

use strict;

use warnings;
use feature qw(say);
use Math::Prime::Util qw(factor_exp gcd);
use Time::HiRes qw(time);

my $time = time;

#-------------------------------------------------------------------------------
for( my( $c, $n ) = $ARGV[0] // 100; $c; ) {
  $c--, say $n if 1 == gcd map{ $_->[1] < 2 ? next : $_->[1] } factor_exp ++$n
}

warn 'Time taken: ', time-$time, "\n"