Commit 32af786
committed
feat: Identify and print prime numbers from 2 to 20 using nested loops
🔍 Logic:
- Outer loop increments through numbers 2 to 20.
- Inner loop checks divisibility from 2 to current number.
- If `divisor == currentNumber`, it means no smaller divisor was found → prime.
- If divisible earlier, print "NOT a prime" and exit inner loop early.
🛠️ Note:
`break` should be used after detecting a non-prime to skip unnecessary checks.
Signed-off-by: Somesh diwan <[email protected]>1 parent 39fb052 commit 32af786
1 file changed
+4
-7
lines changedLines changed: 4 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
| 1 | + | |
| 2 | + | |
5 | 3 | | |
6 | 4 | | |
7 | 5 | | |
8 | 6 | | |
9 | | - | |
10 | | - | |
| 7 | + | |
11 | 8 | | |
12 | 9 | | |
13 | 10 | | |
| |||
25 | 22 | | |
26 | 23 | | |
27 | 24 | | |
28 | | - | |
| 25 | + | |
0 commit comments