aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-022/yet-ebreo/perl5/ch-1.pl7
1 files changed, 7 insertions, 0 deletions
diff --git a/challenge-022/yet-ebreo/perl5/ch-1.pl b/challenge-022/yet-ebreo/perl5/ch-1.pl
new file mode 100644
index 0000000000..b0a1bae4a4
--- /dev/null
+++ b/challenge-022/yet-ebreo/perl5/ch-1.pl
@@ -0,0 +1,7 @@
+# Write a script to print first 10 Sexy Prime Pairs.
+# Sexy primes are prime numbers that differ from each other by 6.
+# For example, the numbers 5 and 11 are both sexy primes, because 11 - 5 = 6.
+# The term “sexy prime” is a pun stemming from the Latin word for six: sex.
+
+@_=grep{@_[ map $x*$_,//..@_/($x=$_) ] =0 if $_[$_] > 1}@_=0..54;
+map { ($_[$_]-$_[$'] == 6) && print "$_[$'] $_[$_]\n" for $_+//..$#_ } 0..$#_;