2

rated 0 times
[
2]
[
0]
/ answers: 1 / hits: 631
/ 1 Year ago, wed, february 1, 2023, 2:58:16

The following program is giving error on line 7 and 9: the `while`

loop does not seem to be working. It is a program to show all the prime and composite numbers from 3 to a desired given input.

`echo prograam to find all the prime numbers from 3 to given number`

echo enter the last number

read number

n=$number

i=3

m=3

while [ $m -le $n ]

do

while [ $i -le $m ]

do

m=`expr $n % $i`

i=`expr $i +1`

if [ $m -eq 0 ]

then

echo $n is a prime number

else

echo $n is not a prime number

fi

done

m=`expr $m +1`

done

More From » scripts