diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2022-02-02 10:09:18 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-02 10:09:18 +0000 |
| commit | fa94229fcb2321c0b2aef98d19dfd3fee18a5699 (patch) | |
| tree | 5cc20d2538e335d9e9a5320f0ee112aae2fe5d87 /challenge-150/abigail/lua/ch-2.lua | |
| parent | 1594215dac459eef085ceadcf8ffe2e7280ffecb (diff) | |
| parent | d007a9c8216764b0ed11bbae7179481f8ad5b1a0 (diff) | |
| download | perlweeklychallenge-club-fa94229fcb2321c0b2aef98d19dfd3fee18a5699.tar.gz perlweeklychallenge-club-fa94229fcb2321c0b2aef98d19dfd3fee18a5699.tar.bz2 perlweeklychallenge-club-fa94229fcb2321c0b2aef98d19dfd3fee18a5699.zip | |
Merge pull request #5599 from Abigail/abigail/week-150
Abigail/week 150
Diffstat (limited to 'challenge-150/abigail/lua/ch-2.lua')
| -rw-r--r-- | challenge-150/abigail/lua/ch-2.lua | 27 |
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") |
