Check for an Adam number Click me to definition for Adam number Code: clear echo -------------------------------- echo '\tAdam or Not' echo -------------------------------- echo Enter the number read n x=$n s=0 s1=0 while [ $n -gt 0 ] do r=$(expr $n % 10) s=$(expr $s \* 10 + $r) n=$(expr $n / 10) done y=$(expr $s \* $s) z=$(expr $x \* $x) while [ $z -gt 0 ] do r1=$(expr $z % 10) s1=$(expr $s1 \* 10 + $r1) z=$(expr $z / 10) done if [ $s1 -eq $y ] then echo The given number is Adam. else echo The given number is not Adam. fi Output: -------------------------------- Adam or Not -------------------------------- Enter the number 13 The given number is Adam.
Leave a Comment