Rem $N: "Enter Numnber: "
Rem $N: "Enter Numnber: "
echo -n "Please enter three numbers (separate number by space) : " read a b c # compare a with b and c. Note -a is logical and operator if [ $a -gt $b -a $a -gt $c ] then big=$a elif then big=$b elif then big=$c elif [ $a -eq $b -a $a -eq $c -a $b -eq $c -a $c -eq $b ] # see if all of them are equal or not then big="All three numbers are same (equal)" else # something must be wrong if we are here, like one of number is character such as 'A' big="Can not guess greaters of three numbers" fi # display result [ $c -gt $a -a $c -gt $b ] # compare c with a and b [ $b -gt $a -a $b -gt $c ] # compare b with a and c
Answer:
Improve
i=2 rem=1 echo "Enter a number" read num if [ $num -lt 2 ] then echo "$num is not prime" exit 0 fi while [ $i -le `expr $num / 2` -a $rem -ne 0 ] do rem=`expr $num % $i` i=`expr $i + 1` done if [ $rem -ne 0 ] then echo "$num is prime" else echo "$num is not prime" fi