Given a number . The tasks is to check if the given number is a Triperfect Number.
Triperfect Number: A Number is a Triperfect Number if it is equal to three times the sum of its divisors, that is, 3 times sum of its positive divisors.
Input: N = 15 Output: false Divisors of 15 are 1, 3, 5 and 15. Sum of divisors is 24 which is not equal to 3*15 i.e. 45. Input: N = 120 Output: true Sum of divisors is 360 i.e. 3*120. Hence 120 is a triperfect number.
A Simple Solution is to go through every number from 1 to N and check if it is a divisor. Maintain sum of all divisors. If sum becomes equal to 3*N, then return true, else return false.
An Efficient Solution is to go through numbers till square root of N. If a number ‘i’ divides n, then add both ‘i’ and n/i to sum.
Below is the implementation of the efficient approach:
120 is a Triperfect number
Some interesting facts about TriPerfect Numbers:
- Till now only 6 Triperfect numbers are known. These are 120, 672, 523776, 459818240, 1476304896 and 51001180160.
- It has not been proven that more Triperfect Numbers don’t exist but it is believed that these are the only six.
Similarly, we can check for quad-perfect numbers(sum of factors = 4*n), five-perfect numbers( sum of factors = 5*n) and so on. There are currently 36 quad-perfect numbers known and 65 five-perfect numbers known.
- Write a program to reverse digits of a number
- Write an Efficient Method to Check if a Number is Multiple of 3
- Write an Efficient C Program to Reverse Bits of a Number
- Minimum number of jumps to reach end
- Find minimum number to be divided to make a number a perfect square
- Find whether a given number is a power of 4 or not
- Print all combinations of points that can compose a given number
- Check if a number is multiple of 5 without using / and % operators
- Check whether a given point lies inside a triangle or not
- Given a number, find the next smallest palindrome
- Check divisibility by 7
- Count the number of possible triangles
- Select a random number from stream, with O(1) space
- Program to convert a given number to words
- Efficient program to print all prime factors of a given number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.