Prime Number Program in Java

preview_player
Показать описание
#BackCoding

Let's see the prime number program in java. In this java program, we will take a number variable and check whether the number is prime or not ⬆️ program.

Prime number in Java: Prime number In other words, prime numbers

#programming
#java
#shorts
Рекомендации по теме
Комментарии
Автор

import java.util.Scanner;

class CheckPrimeNumber{

public static void main (String args[]){

Scanner sc=new Scanner(System.in);
System.out.println("Enter a Number :");
int num=sc.nextInt();

boolean isPrime=true;

if(num>-1){
for(int i=2;i*i<num;i++){
if(num%2==0){
isPrime=false;
}
}
if(isPrime){
System.out.println("The number "+num+" Is prime ");
} else{
System.out.println("The number "+num+" Is Not Prime");

}
}else{
System.out.println("The Number "+num+" Is negative");
}
}
}

BackCoding
Автор

Bro managed to make the code as lengthy as possible

priyanshurawat
Автор

if(num%i==0) { isPrime= false;} this should be written inside that for loop

nitishkumarprusty
Автор

It's completely wrong code😢. Please don't refer this.

amanbhanse
Автор

Else work kaise kr rha is mai joh not prime likh ke aa rha??

CodingDimensions
Автор

yes it is wrong code dont refer anyone

aishwaryaravi