From 44bcd3ae0c35b887bd579e60c17198360f3497c3 Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 30 Nov 2021 20:04:35 +0100 Subject: Solutions week 141 --- challenge-141/abigail/lua/ch-1.lua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 challenge-141/abigail/lua/ch-1.lua (limited to 'challenge-141/abigail/lua/ch-1.lua') diff --git a/challenge-141/abigail/lua/ch-1.lua b/challenge-141/abigail/lua/ch-1.lua new file mode 100644 index 0000000000..f9b626f6a9 --- /dev/null +++ b/challenge-141/abigail/lua/ch-1.lua @@ -0,0 +1,36 @@ +#!/opt/local/bin/lua + +-- +-- See ../README.md +-- + +-- +-- Run as: lua ch-1.lua +-- + +local count = 10 +local nr_of_divisor = 8 + +local n = 0 +while count > 0 do + n = n + 1 + local s = math . floor (math . sqrt (n)) + if n == s * s then + goto end_while + end + local c = 0 + for d = 1, s do + if n % d == 0 then + c = c + 2 + if c > nr_of_divisor then + goto end_while + end + end + end + if c == nr_of_divisor then + print (n) + count = count - 1 + end + + ::end_while:: +end -- cgit