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.
- Count number of trailing zeros in Binary representation of a number using Bitset
- 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
- Smallest number dividing minimum number of elements in the array | Set 2
- Find the number of positive integers less than or equal to N that have an odd number of digits
- Number of times the largest perfect square number can be subtracted from N
- Given number of matches played, find number of teams in tournament
- Number of possible permutations when absolute difference between number of elements to the right and left are given
- 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
- Largest number dividing maximum number of elements in the array
- Print a number strictly less than a given number such that all its digits are distinct.
- Find maximum number that can be formed using digits of a given number
- Count number of digits after decimal on dividing a number
- Minimum number of given powers of 2 required to represent a number