-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloopflow.java
More file actions
150 lines (134 loc) · 3.87 KB
/
Copy pathloopflow.java
File metadata and controls
150 lines (134 loc) · 3.87 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import java.util.Scanner;
public class loopflow {
// public static void main(String args[]){
// int counter = 0;
// while(counter < 10)
// {
// System.out.println("Hello");
// counter++;
// }
// System.out.println("Printed hello 10x");
// public static void main(String args[]) {
// int counter = 1;
// while (counter<=10) {
// System.out.print(counter+" ");
// counter++;
// }
// System.out.println();
// }
// public static void main(String args[]) {
// System.out.print("Enter the valu upto which you want to print the number\n");
// Scanner sc = new Scanner(System.in);
// int range = sc.nextInt();
// int counter = 1;
// while (counter <= range) {
// System.out.print(counter + " ");
// counter++;
// }
// System.out.println();
// }
// public static void main(String args[])
// {
// System.out.print("Enter the value of n upto which you want the sum of\n");
// Scanner sc = new Scanner(System.in);
// int n = sc.nextInt();
// int sum = 0;
// int i = 1;
// while(i<=n)
// {
// sum = sum + i;
// i++;
// }
// System.out.print("The sum of first "+n+" digit is "+sum);
// }
// Square pattern using for loop
// public static void main(String args[])
// {
// for(int i = 0;i<=4;i++)
// {
// for(int j = 0; j<= 4; j++)
// {
// System.out.print(" * ");
// }
// System.err.println();
// }
// }
// PRINT REVERSE OF A NUMBER
// public static void main(String[] args) {
// System.out.print("Enter the number you want to reverse:\n");
// Scanner sc = new Scanner(System.in);
// int n = sc.nextInt();
// int rev = 0;
// while (n!= 0) {
// rev = n%10;
// System.out.print( rev);
// n = n/10;
// }
// }
// DO WHILE LOOP
// public static void main(String[] args) {
// int counter = 1;
// do{
// System.out.println("Helo world");
// counter ++;
// }
// while(counter<10);
// }
// BREAK STATEMENT
// public static void main(String[] args) {
// for (int i = 0; i < 10; i++) {
// if (i == 3) {
// break;
// }
// System.out.println(i);
// }
// }
// QUESTION USING BREAK STATEMENT
// public static void main(String args[])
// {
// Scanner sc = new Scanner(System.in);
// do{
// System.out.println("Enter your number: ");
// int n = sc.nextInt();
// if(n%10 == 0)
// {
// break;
// }
// System.out.print(n);
// }
// while(true);
// }
// CONTINUE STATEMENT
// public static void main(String[] args) {
// for(int i = 1; i<= 5;i++)
// {
// if (i == 3)
// {
// continue;
// }
// System.out.println(i);
// }
// }
// PRIME OR NOT
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
boolean isPrime = true;
for(int i=2; i<=n-1; i++)
{
if(n%i == 0)
{
isPrime = false;
}
}
if(isPrime == true)
{
System.out.println("is Prime");
}
else
{
System.out.println("not Prime");
}
}
}