Given a positive integer n, check if it is an Ore number or not. Print ‘YES’ if n is an ore number otherwise print ‘NO’.
Ore Number : In mathematics, Ore numbers are positive integers whose divisors have a integer harmonic value. Ore numbers are often called as harmonic divisor number. Ore numbers are named after Øystein Ore.
For example, 6 has four divisors namely 1, 2, 3 and 6.
Harmonic mean of the divisors is-
The harmonic mean of divisors of 6 is 2, an integer. So, 6 is an Ore number or harmonic divisor number.
First few Ore numbers or harmonic divisor numbers are:
1, 6, 28, 140, 270, 496, 672, 1638, 2970, 6200, 8128, 8190
Input : N = 6 Output : Yes Input : N = 4 Output: No Explanation : Harmonic mean of divisors of 4 is not an Integer.
The idea is to generate all divisors of the given number and then check if the harmonic mean of the divisor is an Integer or not.
- Generate All Divisors of the given number – ‘n’
- Calculate Harmonic mean of the divisors of n
- Check if Harmonic mean is an Integer or not
- If Yes, Then the number is an Ore Number otherwise Not
Below is the implementation of above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Check if given number is Emirp Number or not
- Check whether the given number is Euclid Number or not
- Check whether given number N is a Moran Number or not
- Check whether a given number N is a Nude Number or not
- Check whether a given number is an ugly number or not
- Check whether a given number is Polydivisible or Not
- Check whether a given Number is Power-Isolated or not
- Check whether the given number is Wagstaff prime or not
- Check whether a number has consecutive 0's in the given base or not
- Check if the given number is divisible by 71 or not
- Check whether the binary equivalent of a number ends with given string or not
- Check whether a given point lies inside a triangle or not
- Check if the given two numbers are friendly pair or not
- Check if a given matrix is Hankel or not
- Check if the given 2-D points form T-shape or not
- Check whether the given numbers are Cousin prime or not
- Check if the given vectors are at equilibrium or not
- Check if given two straight lines are identical or not
- Check if the given Prufer sequence is valid or not
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.