Skip to content

Commit 994ad6c

Browse files
authored
Add files via upload
1 parent 8e43f45 commit 994ad6c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Numbers/Basic_Programs/Main.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import java.util.Scanner ;
2+
class Main
3+
{
4+
public static void main(String[] ags)
5+
{ Scanner read = new Scanner(System.in);
6+
int i, n;
7+
System.out.println("Enter the number till which you wish to finad all the prime no.s : ");
8+
n=read.nextInt();
9+
System.out.println(" Prime numbers from 1 to "+n+ " are : ");
10+
for(i=2;i<=n;i++)
11+
{ if((i==2)||(i==3)||(i==5)||(i==7)||(i==11)||(i==13)||(i==17))
12+
{ System.out.println(i+"\t"); }
13+
else
14+
{ if((i%2!=0)&&(i%3!=0)&&(i%5!=0)&&(i%7!=0)&&(i%11!=0)&&(i%13!=0)&&(i%17!=0))
15+
System.out.println(i+"\t"); }
16+
}
17+
18+
}
19+
}

0 commit comments

Comments
 (0)