Free help with homework

Why join Brainly?

  • ask questions about your assignment
  • get answers with explanations
  • find similar questions

How to write a program to check wethera number is prime number or number which is taken as an input?

please help me it is urgent other it will be no use to answer it>>

yes yes
no no bluej
i'm sorry.. i can write a c++ code if u want..
then what


I'm writing this in simple way so you are able to understand.
A Prime Number is that number which is divisible by only 1 and itself.
Example: 17.It is only divisible by 1 and 17 ,hence it is a prime number.

class checkPrime {
public static void main(int number)
int counter=0;
for(int i=1; i<=number; i++)
   if ( number%i==0 )
System.out.println(" Number is Prime");
System.out.println("Number is not Prime");

0 0 0
The Brain
  • The Brain
  • Helper
Not sure about the answer?
Learn more with Brainly!
Having trouble with your homework?
Get free help!
  • 80% of questions are answered in under 10 minutes
  • Answers come with explanations, so that you can learn
  • Answer quality is ensured by our experts