To calculate this in Linux the below script can be used.
Pass the word as first argument to calculate its sum in words.
#!/bin/bash
initial=1
for alpha in {a..z}
do
let $alpha=$initial
initial=`expr $initial + 1`
done
word="$1"
length=${#word}
base=0
offset=1
final=0
while [ $base -lt $length ]
do
semi=$(($(echo ${word:base:offset})))
let final=`expr $final + $semi`
let base++
done
echo "Numeric value of $word is $final"
No comments:
Post a Comment