aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-156/robert-dicicco/bash/ch-1.bash25
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-156/robert-dicicco/bash/ch-1.bash b/challenge-156/robert-dicicco/bash/ch-1.bash
new file mode 100644
index 0000000000..e09cefb739
--- /dev/null
+++ b/challenge-156/robert-dicicco/bash/ch-1.bash
@@ -0,0 +1,25 @@
+#!usr/bin/env bash
+
+# AUTHOR: Robert DiCicco
+# DATE: 16-MAR-2022
+# Challenge 156 Pernicious Numbers ( Bash )
+
+Primes=' 2 3 5 7 11 13 17 19 23 29 '
+Cnt=0
+Num=1
+
+until [[ $Cnt -eq 10 ]]
+do
+ BinNum=`echo "obase=2;$Num" | bc`
+ res="${BinNum//[^1]}"
+ rescnt=${#res}
+
+ if grep -q " $rescnt " <<< "$Primes"; then
+ echo -n "$Num "
+ ((Cnt=Cnt+1))
+ fi
+
+ ((Num=Num+1))
+done
+
+echo " "