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 firstname.lastname@example.org. 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.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Number of factors of very large number N modulo M where M is any prime number
- Count number of trailing zeros in Binary representation of a number using Bitset
- Find the largest number smaller than integer N with maximum number of set bits
- Find minimum number to be divided to make a number a perfect square
- Count number of triplets with product equal to given number with duplicates allowed
- Given number of matches played, find number of teams in tournament
- Smallest number dividing minimum number of elements in the array | Set 2
- Number of distinct ways to represent a number as sum of K unique primes
- Largest number dividing maximum number of elements in the array
- Number of ways to split a binary number such that every part is divisible by 2
- Smallest number dividing minimum number of elements in the Array
- Find smallest possible Number from a given large Number with same count of digits
- Minimum divisor of a number to make the number perfect cube
- Minimum number of swaps required to make a number divisible by 60
- Find the number of positive integers less than or equal to N that have an odd number of digits