Professional Documents
Culture Documents
C Prog
C Prog
*/
START
Initialize i =2
no
no i=i+1
no
Is j<=sqrt(i) ?
yes
no J=j+1
STOP
#include<stdio.h> #include<conio.h> #include<math.h> void main() { int i,j,n,k=0; clrscr(); printf("Enter the last term of the series\n"); scanf("%d",&n); printf("The prime numbers are:\n"); for(i=2;i<=n;i++) { k=0; for(j=2;j<=sqrt(i);j++) { if(i%j==0) k=1; } if(k==0) printf("%d\t",i); } getch(); } //printing condition of prime numbers //checking the condition of the prime number //starting loop of divisor for 1 to square root of the taken number //starting loop for each natural number up to the given number except 1
OUTPUT:
Enter the last term of the series 30 The prime numbers are: 2 3 5 7 11 13 17 19 23 29