Can help you with the logic (in JAVA)
- Take input of any positive integer by the user
- Use IF-Else statement with condition that input integer should be >0,else print Input is not positive integer (in the Else block)
- In the IF block , now we have a positive integer. Use "for" loop from i= 1 to i= integer itself
- In the for block use IF-Else statement with condition that if integer % i==0(when integer is divided by i remainder=0) then counter++ or counter=counter+1 where counter is just a variable with initial value=0
- Else continue the loop with i++ or i=i+1
4. Outside the loop use IF-Else statement with condition that if counter==2 (that means divisible by 1 and number itself) then print that number is a prime number, else print it is a composite number