answersLogoWhite

0


Best Answer

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

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a unix shell program to print the prime numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Math & Arithmetic
Related questions

Program for print prime all number from 1 to 100 in foxpro?

Prime numbers are numbers that are only divisible by themselves and the number 1. You can write a program to print all prime numbers from 1 to 100 in FoxPro.


Write a program to print first 100 alternative prime numbers?

This would require some computer knowledge. It can make it easier to find out the prime numbers without figuring it out in your head.


Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


Q2 Write a program to print even numbers between 10 and 50?

You can use int i; for (i = 10; i <= 50; i += 2) {//print i} as a program to print even numbers between 10 and 50.


Write a C Program to print sum of squares of odd numbers?

#include


What BASIC program can compute and display all prime numbers from 1 to 40?

PRINT 2,3,5,7,11,13,17,19,23,29,31,37


How do you write a program to print numbers to 50 except prime?

First, create a for loop from a,1 to 50. Inside of that create another for loop b,2 to a-1. If a/b=int(a/b) then you know it is not prime


Write a c program to print prime numbers from 1 to 10000 that has an unit digit which is multiple of 3?

This is a homework question and does not deserve an answer because you will learn nothing other than being lazy.


How do you write a Qbasic program to display these Numbers-0112358132134?

you do this 10 print "0112358132134" use the whole of the thing


Write an assembly language program to print a to z on screen?

write a program to print A to Z on screen in c?


Write a C program to find the prime numbers from 1 to 300?

/*the program to print prime no from 1 to 300*/ #include<stdio.h> #include<conio.h> void main() { int i,j; clrscr(); printf("The prime numbers from 1 to 300 are\n"); for(j=2;j<=300;j++) { for(i=2;i<=j/2;i++) if(j%i==0) break; if(i>j/2) { printf("%d ",j); } } }


How do you write a program to print numbers from star one and next line star two in php?

Try the triangle program on a search engine. Replace numbers with stars and that should do the trick