aboutsummaryrefslogtreecommitdiff
path: root/challenge-150/abigail/bash
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-150/abigail/bash')
-rw-r--r--challenge-150/abigail/bash/ch-1.sh22
-rw-r--r--challenge-150/abigail/bash/ch-2.sh23
2 files changed, 45 insertions, 0 deletions
diff --git a/challenge-150/abigail/bash/ch-1.sh b/challenge-150/abigail/bash/ch-1.sh
new file mode 100644
index 0000000000..b45b0b36a7
--- /dev/null
+++ b/challenge-150/abigail/bash/ch-1.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+#
+# See https://theweeklychallenge.org/blog/perl-weekly-challenge-150
+#
+
+#
+# Run as: bash ch-1.sh < input-file
+#
+
+set -f
+
+LENGTH=51
+
+while read fib_prev fib_last
+do while ((${#fib_last} < LENGTH))
+ do fib_tmp=$fib_last
+ fib_last=$fib_prev$fib_last
+ fib_prev=$fib_tmp
+ done
+ echo ${fib_last:$((LENGTH - 1)):1}
+done
diff --git a/challenge-150/abigail/bash/ch-2.sh b/challenge-150/abigail/bash/ch-2.sh
new file mode 100644
index 0000000000..0fe90e5309
--- /dev/null
+++ b/challenge-150/abigail/bash/ch-2.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+#
+# See https://theweeklychallenge.org/blog/perl-weekly-challenge-150
+#
+
+#
+# Run as: bash ch-2.sh
+#
+
+set -f
+PRIMES=(2 3 5 7 11 13 17 19)
+
+for ((n = 1; n <= 500; n ++))
+do for p in ${PRIMES[@]}
+ do if ((n % (p * p) == 0))
+ then continue 2
+ fi
+ done
+ printf "%d " $n
+done
+
+echo