Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

prime number or not

Wicked Worm answered on March 9, 2023 Popularity 6/10 Helpfulness 1/10

Contents


More Related Answers

  • Prime Number Checker
  • prime number program
  • how to find a prime number
  • check if number is prime
  • what are prime numbers
  • prime number
  • prime number
  • prime numbers
  • what is prime number
  • prime numbers
  • is 1 a prime number
  • checks if a number is a prime number
  • prime numbers
  • write a solution to determine if a number is a prime number
  • Prime number
  • prime no
  • verify prime number
  • Prime Number Checker
  • how to tell if a number is prime by division
  • A prime number is an integer greater than one that is only divisible by one and itself. Write a function called PrimeCheker that determines whether or not its parameter is prime, returning True if it is, and False otherwise. Concretely, the function shoul
  • prime number
  • identify if a number is prime
  • Prime number
  • find prime number
  • Prime number formula

  • prime number or not

    0

    public class PrimeorNot {

    public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt(); //Test case : 32,452,843 is a prime number

    sc.close();

    boolean isPrime = true;

    for(int i=2 ; i<=Math.sqrt(n) ; i++) {

    if(n%i==0)

         isPrime = false;

    }

    if(isPrime) 

         System.out.println("Prime");

    else 

         System.out.println("Not prime");

    }

    Popularity 6/10 Helpfulness 1/10 Language java
    Source: Grepper
    Tags: java
    Link to this answer
    Share Copy Link
    Contributed on Mar 09 2023
    Wicked Worm
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.