Bash script to display prime numbers.
Links that you may find important :
https://en.wikipedia.org/wiki/Prime_number
http://en.wikipedia.org/wiki/List_of_prime_numbers
http://en.wikipedia.org/wiki/2_%28number%29
Code :
Links that you may find important :
https://en.wikipedia.org/wiki/Prime_number
http://en.wikipedia.org/wiki/List_of_prime_numbers
http://en.wikipedia.org/wiki/2_%28number%29
Code :
echo 'Enter no' read x n=2 while [ $n -le $x ] do i=2 count=1 while [ $i -lt $n ] do if [ `expr $n % $i` -eq 0 ] then count=0 break fi i=`expr $i + 1` done if [ $count -eq 1 ] then echo "$n is Prime" fi n=`expr $n + 1` doneOutput :
2 is Prime 3 is Prime 5 is Prime 7 is PrimeNote : Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don't match. Please report about broken links.
2 is not prime it is even number
ReplyDelete