Data Structure and Algorithms in Java

A prime number is a natural number greater than 1 that has no positive divisors other than
1 and itself.
On the other hand, a composite number is a natural number greater than 1 that is not a
prime number.
For example, 5 is prime, as only 1 and 5 divide it, whereas 6 is composite, since it has the
divisors 2 and 3 in addition to 1 and 6.
Write a java method isPrimeNum that takes the number n, and checks whether the number
is prime or composite. The method should print at the end a message that indicates whether
n is prime or composite.

asked by ahmad

Respond to this Question

First Name

Your Response

Similar Questions

  1. math

    Can someone help me with prime and composite numbers? Prime numbers are counting numbers that can be divided evenly bt only two numbers:1 and themselves. A prime number can also be described as a counting number with exactly two
  2. Math

    Find the smallest number N such that: The number of divisors of N is A. The number of divisors of A is B. The number of divisors of B is C. The number of divisors of C is 3. Details and assumptions The divisors include 1 and the
  3. Math

    The number p is the product of three different positive prime numbers greater than 2.If the sum of these three prime number is also prime, what is the smallest possible value for p? Won't the 3 number be 3-5-11? Thanks
  4. Sigma over Phi

    Let σ(n) be the sum of the positive divisors of an integer n and ϕ(n) be the number of positive integers smaller than n that are coprime to n. If p is a prime number, what is the maximum value σ(p)/ϕ(p)?
  5. maths

    Let σ(n) be the sum of the positive divisors of an integer n and ϕ(n) be the number of positive integers smaller than n that are coprime to n. If p is a prime number, what is the maximum value σ(p)ϕ(p)?
  6. mathematics

    Let σ(n) be the sum of the positive divisors of an integer n and ϕ(n) be the number of positive integers smaller than n that are coprime to n. If p is a prime number, what is the maximum value σ(p)ϕ(p)?
  7. math

    Aliquot divisors are all the divisors of a number except the number itself. The product of the Aliquot divisors of a number is somtimes equal to the square of the number. The Aliquot divisors of of 12 are 1 ,2 ,3 ,4 ,6. Their
  8. Math

    A positive integer n is defined as a "prime interlude" if n-1 and n+1 are both prime numbers. Which of the following is not a "prime interlude?" a.4 b.18 c.30 d.72 e.90 ( First of all; What is a "prime interlude??") I don't
  9. Math

    the only perfect number of the form x(n) + y(n) A perfect number is an integer that is equal to the sum of its positive divisors (not including itself). Therefore, 6 is a perfect number, since its positive divisors are 1, 2, and 3
  10. math

    Find the smallest positive integer not relatively prime to 2015 that has the same number of positive divisors as 2015.

More Similar Questions