forked from animeshprasad15/C
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprime.c
More file actions
28 lines (28 loc) · 645 Bytes
/
prime.c
File metadata and controls
28 lines (28 loc) · 645 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<stdio.h>
#include<math.h>
int main()
{
int i,n;
printf("Enter a number :");
scanf("%d",&n);
for(int j=1;j<=n;j++)
{
//int l=j;
int temp=0;
for(i=2;i<=sqrt(j);i++)
{
if(j%i==0)
{
temp=1;
break;
}
}
if(temp==0)
printf("%d\t",j);
}
return 0;
}
//Output
// Enter a number :100
// 1 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61
// 67 71 73 79 83 89 97