aboutsummaryrefslogtreecommitdiff
path: root/challenge-003/abigail/lua/ch-1.lua
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-003/abigail/lua/ch-1.lua')
-rw-r--r--challenge-003/abigail/lua/ch-1.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/challenge-003/abigail/lua/ch-1.lua b/challenge-003/abigail/lua/ch-1.lua
new file mode 100644
index 0000000000..70de9b1923
--- /dev/null
+++ b/challenge-003/abigail/lua/ch-1.lua
@@ -0,0 +1,30 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-1.lua < input-file
+--
+
+for max in io . lines () do
+ local max = tonumber (max)
+ local base2 = 1
+ --
+ -- Lua doesn't have a for (expr; expr; expr) syntax.
+ -- This is missed here.
+ --
+ while base2 <= max do
+ local base3 = base2
+ while base3 <= max do
+ local base5 = base3
+ while base5 <= max do
+ print (base5)
+ base5 = base5 * 5
+ end
+ base3 = base3 * 3
+ end
+ base2 = base2 * 2
+ end
+end