We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8e43f45 commit 994ad6cCopy full SHA for 994ad6c
Numbers/Basic_Programs/Main.java
@@ -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