June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
15
Task/Digital-root/UNIX-Shell/digital-root.sh
Normal file
15
Task/Digital-root/UNIX-Shell/digital-root.sh
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
numbers=(627615 39390 588225 393900588225 55)
|
||||
declare root
|
||||
|
||||
for number in "${numbers[@]}"; do
|
||||
declare -i iterations
|
||||
root="${number}"
|
||||
while [[ "${#root}" -ne 1 ]]; do
|
||||
root="$(( $(fold -w1 <<<"${root}" | xargs | sed 's/ /+/g') ))"
|
||||
iterations+=1
|
||||
done
|
||||
echo -e "${number} has additive persistence ${iterations} and digital root ${root}"
|
||||
unset iterations
|
||||
done | column -t
|
||||
Loading…
Add table
Add a link
Reference in a new issue