Suppose we have a number n. We have to check whether n is an ore number or not. As we know an ore number is a number whose divisors have an integer harmonic value.
So, if the input is like 28, then the output will be True as there are six divisors of 28: [1, 2, 4, 7, 14, 28], so
As 3 is an integer so 28 is an ore number.
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
def get_all_div(n): div =  for i in range(1, int(n**(0.5)) + 1): if n % i == 0: if n // i == i: div.append(i) else: div.append(i) div.append(n // i) return div def get_harmonic_mean(n): div = get_all_div(n) total = 0 length = len(div) for i in range(0, length): total += (n / div[i]) total /= n return length / total def solve(n): mean = get_harmonic_mean(n) if mean - int(mean) == 0: return True return False n = 28 print(solve(n))