Solution:
What is a Prime Number?
A prime number is a natural number greater than 1 that is only divisible by 1 and itself.
Before writing the logic first we need to think logic then it will be easy to write the code
To determine if a number is prime:
If the number is less than or equal to 1 → Not prime.
Check all numbers from 2 to n-1:
If the number is divisible by any of them → Not prime.
If none divide it → It is prime.
Example:
1 (Not prime)
4 (Divisible by 1, 2, 4)
6 (Divisible by 1, 2, 3, 6)
That’s how we do it! Done and dusted! 🧹😄
output:
Enter a positive integer: 13
13 is a prime number.
Enter a positive integer: 9
9 is not a prime number.
Enter a positive integer: 1
1 is not a prime number.
Note:Your code should pass all the test cases then only you will get full marks if you see above i given different scenarios those all are different test cases.