aboutsummaryrefslogtreecommitdiff
path: root/challenge-150/abigail/node/ch-2.js
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-150/abigail/node/ch-2.js')
-rw-r--r--challenge-150/abigail/node/ch-2.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-150/abigail/node/ch-2.js b/challenge-150/abigail/node/ch-2.js
new file mode 100644
index 0000000000..1b9e5aac34
--- /dev/null
+++ b/challenge-150/abigail/node/ch-2.js
@@ -0,0 +1,23 @@
+#!/usr/local/bin/node
+
+//
+// See https://theweeklychallenge.org/blog/perl-weekly-challenge-150
+//
+
+//
+// Run as: node ch-2.js
+//
+
+let primes = [2, 3, 5, 7, 11, 13, 17, 19];
+for (let n = 1; n <= 500; n ++) {
+ let has_square = false
+ primes . forEach (p => {
+ if (n % (p * p) == 0) {
+ has_square = true
+ }
+ })
+ if (!has_square) {
+ process . stdout . write (n . toString () + " ")
+ }
+}
+process . stdout . write ("\n")