aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2022-01-03 11:27:40 +0000
committerdrbaggy <js5@sanger.ac.uk>2022-01-03 11:27:40 +0000
commit64a0a51857212b0264b7b193830a93c3dd5ff80e (patch)
tree1ba8dd16acbc5fe2cd3326b6b53bd3e31eafd909
parent41f8dae6667e8b4215b9f2507d7a2e14236890b9 (diff)
downloadperlweeklychallenge-club-64a0a51857212b0264b7b193830a93c3dd5ff80e.tar.gz
perlweeklychallenge-club-64a0a51857212b0264b7b193830a93c3dd5ff80e.tar.bz2
perlweeklychallenge-club-64a0a51857212b0264b7b193830a93c3dd5ff80e.zip
prime soln
-rw-r--r--challenge-146/james-smith/perl/ch-1.pl14
-rw-r--r--challenge-146/james-smith/perl/ch-2.pl22
2 files changed, 36 insertions, 0 deletions
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;
+}
+