Sha256: e8cfff69e01cbe34a64432af42343aa5577d1c382ed286cdd2f8f6f092b0352b
Contents?: true
Size: 583 Bytes
Versions: 95
Compression:
Stored size: 583 Bytes
Contents
#!/bin/bash num=$(echo "$1" | sed 's/[\ ]//g') if ! [[ 10#$num -ge 0 ]] 2>/dev/null || ! [[ ${#num} -gt 1 ]] ; then echo "false" else shift 1 len=${#num} is_odd=1 sum=0 for((t = len - 1; t >= 0; --t)) { digit=${num:$t:1} if [[ $is_odd -eq 1 ]]; then sum=$(( sum + $digit )) else sum=$(( $sum + ( $digit != 9 ? ( ( 2 * $digit ) % 9 ) : 9 ) )) fi is_odd=$(( ! $is_odd )) } if [[ 0 -eq $(( 0 != ( $sum % 10 ) )) ]] ; then echo "true" else echo "false" fi fi
Version data entries
95 entries across 95 versions & 1 rubygems