Commit f05b5ec
committed
feat: Add Prime class to check whether a number is prime using optimized loop
Add a program that:
- Accepts an integer input from the user
- Handles edge cases like numbers ≤ 1
- Uses an optimized loop to check divisibility up to √n
- Prints whether the number is Prime or Not Prime
- Demonstrates control flow, loop efficiency, and conditional logic in Java.1 parent a6557c6 commit f05b5ec
1 file changed
+3
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
24 | | - | |
25 | 27 | | |
26 | 28 | | |
0 commit comments