Given an integer n. Check whether the number is refactorable or not. A refactorable number is an integer n that is divisible by count of all it’s divisors.
Input: n = 8 Output: yes Explanation: 8 has 4 divisors: 1, 2, 4, 8 Since 8 is divisible by 4 therefore 8 is refactorable number. Input : n = 4 Output: no
This solution is pretty straightforward. The idea is to iterate from 1 to sqrt(n) and count all the divisors of a number. After that we just need to check whether the number n is divisible by it’s total count or not.
Output: yes no
Time complexity: O(sqrt(n))
Auxiliary space: O(1)
Facts about refactorable number
- There is no refactorable number which is perfect.
- There is no three consecutive integers can all be refactorable.
- Refactorable number have natural density zero.
This article is contributed by Shubham Bansal. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- 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
- Given a number, find the next smallest palindrome
- 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
- Check if a number is Palindrome
- Random number generator in arbitrary probability distribution fashion