Created
November 23, 2022 03:00
-
-
Save neuthral/1cda78af564a8cb609854952d9e4553d to your computer and use it in GitHub Desktop.
count together numbers in a string until only one number from 1 - 9 remains [??vortex math??]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
STRING=$1 | |
NUM=0 | |
until [[ $STRING -lt 10 ]] do; | |
foreach n in $(echo $STRING | fold -w1); do | |
echo "$NUM + $n"; | |
((NUM=NUM+n)); | |
echo " = $NUM"; | |
done; | |
((STRING=NUM)); | |
((NUM=0)); | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment