**Ore number** is a positive integer whose divisors have a harmonic value as an integer. Ore number is also known as harmonic divisor number.

For example, 6 has four factors: 1, 2, 3 and 6.

Harmonic mean of the factors is:

4 / (1 + 1 / 2 + 1 / 3 + 1 / 6) = 2

The harmonic mean of the factors of 6 is 2, which is an integer.

So, 6 is an Ore number or harmonic divisor number.

Write a program in **Java** to input an integer and check whether it is an Ore Number or not.

```
import java.io.*;
class Ore{
public static void main(String args[])throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number: ");
int num = Integer.parseInt(br.readLine());
int f = 0;
double mean = 0.0;
for(int i = 1; i <= num; i++){
if(num % i == 0){
f++;
mean += 1.0 / i;
}
}
mean = f / mean;
if(mean == (int)mean)
System.out.println(num + " is an Ore Number.");
else
System.out.println(num + " is NOT an Ore Number.");
}
}
```

## 2 replies on “Ore Number Program in Java”

Sir,a program is given which states that:

WAP in Java to accept n integers in SDA(single dimensional array). Now remove all the prime numbers from the array and display the resultant array.

Sample Input:

N=10

1

2

3

4

5

6

7

8

9

10

Resultant array:

1 4 6 8 9 10

Sir,I have tried the program by this way but the output is not coming.

import java.util.Scanner;

class DeletePrime{

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);

System.out.print(“M = “);

int m = sc.nextInt();

if(m<=0){

System.out.println("Size out of range");

System.exit(0);

}

int a[]=new int[m];

int b[];

int i,j,s=0;boolean status=true;

j=0;

System.out.println("Enter array elements:");

for(i=0;i<m;i++)

a[i]=sc.nextInt();

b=new int[a.length];

for(i=0;i<a.length;i++){

if(isPrime(a[i],2)==false)

{

b[j++]=a[i];

s++;

}

}

b=new int[s];

System.out.println("New Array:");

for(i=0;i

~~f)~~return false;

else if(num<2)

return false;

else if(num==f)

return true;

else{

f++;

return isPrime(num,f);

}

}

}

Sir,can you please show the mistakes where I have made?

Sir,Can you show me the program for deleting prime numbers?

Sir,a program is given which states that:

WAP in Java to accept n integers in SDA(single dimensional array). Now remove all the prime numbers from the array and display the resultant array.

Sample Input:

N=10

1

2

3

4

5

6

7

8

9

10

Resultant array:

1 4 6 8 9 10