From 64a0a51857212b0264b7b193830a93c3dd5ff80e Mon Sep 17 00:00:00 2001 From: drbaggy Date: Mon, 3 Jan 2022 11:27:40 +0000 Subject: prime soln --- challenge-146/james-smith/perl/ch-1.pl | 14 ++++++++++++++ challenge-146/james-smith/perl/ch-2.pl | 22 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 challenge-146/james-smith/perl/ch-1.pl create mode 100644 challenge-146/james-smith/perl/ch-2.pl diff --git a/challenge-146/james-smith/perl/ch-1.pl b/challenge-146/james-smith/perl/ch-1.pl new file mode 100644 index 0000000000..fe3c61704e --- /dev/null +++ b/challenge-146/james-smith/perl/ch-1.pl @@ -0,0 +1,14 @@ +#!/usr/local/bin/perl + +use strict; + +use warnings; +use feature qw(say); + +my @primes = (2); + +for( my $c=3; @primes<10001; $c+=2 ) { + ($_>sqrt$c)?((push@primes,$c),last):$c%$_||last for @primes; +} + +say $primes[-1]; diff --git a/challenge-146/james-smith/perl/ch-2.pl b/challenge-146/james-smith/perl/ch-2.pl new file mode 100644 index 0000000000..2348c8b946 --- /dev/null +++ b/challenge-146/james-smith/perl/ch-2.pl @@ -0,0 +1,22 @@ +#!/usr/local/bin/perl + +use strict; + +use warnings; +use feature qw(say); +use Test::More; +use Benchmark qw(cmpthese timethis); +use Data::Dumper qw(Dumper); + +my @TESTS = ( + [ 0, 1 ], +); + +is( my_function($_->[0]), $_->[1] ) foreach @TESTS; + +done_testing(); + +sub my_function { + return 1; +} + -- cgit