Sha256: ecd849ad8388da27cecbb8134bad985b076a48a78fa8e8b9b25741257afa849b
Contents?: true
Size: 374 Bytes
Versions: 93
Compression:
Stored size: 374 Bytes
Contents
#!/usr/bin/env bash is_armstrong() { sum=0 number=$1 power=${#number} index=1 while [ $index -le ${#number} ]; do digit=$(echo ${number} | cut -c${index}-${index}) sum=$(expr $sum + $(($digit**$power))) index=$(expr $index + 1) done if [ $sum -eq $number ]; then echo "true" exit 0 else echo "false" exit 1 fi } "$@"
Version data entries
93 entries across 93 versions & 1 rubygems