aboutsummaryrefslogtreecommitdiff
path: root/challenge-150/abigail/lua/ch-2.lua
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-150/abigail/lua/ch-2.lua')
-rw-r--r--challenge-150/abigail/lua/ch-2.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-150/abigail/lua/ch-2.lua b/challenge-150/abigail/lua/ch-2.lua
new file mode 100644
index 0000000000..f3e4862279
--- /dev/null
+++ b/challenge-150/abigail/lua/ch-2.lua
@@ -0,0 +1,27 @@
+#!/opt/local/bin/lua
+
+--
+-- See https://theweeklychallenge.org/blog/perl-weekly-challenge-150
+--
+
+--
+-- Run as: lua ch-2.lua
+--
+
+local primes = {2, 3, 5, 7, 11, 13, 17, 19}
+local max = 500
+
+for n = 1, max do
+ local has_square = 0
+ local p
+ for _, p in ipairs (primes) do
+ if n % (p * p) == 0 then
+ has_square = 1
+ end
+ end
+ if has_square == 0 then
+ io . write (n)
+ io . write (" ")
+ end
+end
+io . write ("\n")