Javatpoint Logo
Javatpoint Logo

ORE Number Java

The ORE number is a special positive number which is also known as a harmonic divisor number. A number is said to be ORE if its divisors have a harmonic value as an integer. Unlike Prime and Armstrong numbers, the ORE number is rarely asked by the interviewers.

Let's take some examples of ORE numbers.

  1. 6 is an ORE number because its harmonic mean of the divisor, i.e., 2 is an integer.
  2. 4 is not an ORE number because its harmonic mean of the divisor is not an integer.
  3. 28 is also an ORE number because its harmonic mean of the divisor, i.e., 4 is an integer.

Let's understand how we can calculate the harmonic mean of the number mathematically:

Number=6

Factors of number 6=1,2,3,and 6

Harmonic mean = n / (∑1/xi)

Here, n is the number of factors, and x is the value of the factor. So,

ORE Number Java

The harmonic mean of the number 6 is 2, i.e., a positive integer value, so it is an ORE number.

Steps to check ORE number

In order to check whether the number is ORE or not, we have to follow the following steps:

  • We first take a number from the user to check.
  • After that, we find all the divisors of that number to find the harmonic mean.
  • Next, we calculate the harmonic mean of the number using the divisors list.
  • If the harmonic mean of the number is an integer, we print "number is an ORE number.". Otherwise, print "number is not an ORE number.".

Note: In order to find the harmonic mean of the number, we have to implement our own logic. There is no predefined function to get the harmonic mean of the number.

Let's implement the code to check whether the number is an ORE number or not.

ORENumber.java

Output:

ORE Number Java

FindAllORENumbers.java

Output:

ORE Number Java





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA