Program To Check Whether A Number Is Prime OR Not | Study Table
Program To Check Whether
A Number Is
Prime OR Not
- What is 'Prime Number'?
Ans. A prime number is a number that is only divisible by 1
or itself. Example : 2, 3, 5, 7, 11.
Program
class Prime{
public static void main(String ARGS[]){
for(int i=2;i<no-1;i++){
if (no%i==0){
temp=temp+1;
}
}
if(temp>0){
System.out.println("No. is not prime");
}
else{
System.out.println("No. is Prime");
}
}
}
// So this is a simple program to check whether a given number is Prime or not.
I hope you have understood the program concept now.
For more codes and videos visit my Youtube channel :
https://youtube.com/channel/UC27TQ7zJKapHF78bwvi5iVw
For more Posts based on Programming visit my Blog:http://studytable10.blogspot.com/
Also, join my telegram:https://t.me/studytable10
Thanks!!
Thanks!!
Comments
Post a Comment
What's in your mind?