ARMSTRONG NUMBER
echo"Enter the number"
read n
t=$n
s=0
b=0
c=10
while[$n -st $b]
do
r=expr $n%$c
i=expr $r *$r*$r
s=expr $s + $i
n=expr $n / $c
done
echo a$s
if[ $s -eq $t]
then
echo"Armstrong number"
else "Not an Armstrong number"
fi
THE GIVEN NUMBER IS PRIME OR NOT
echo"Enter a number:"
read n
flag=0
for((i=2;i<=n/2;i++))
do
r=expr $n %$i
if[ $r = 0]
then
flag=1
break
fi
done
if [ $flag = 0]
then
echo"$n is a prime number"
else
echo"$n is not a prime number"
fi
0 comments:
Post a Comment