Given a number “n”, find its total number of divisors is even or odd.
Input: n = 10 Output: Even Input: n = 100 Output: Odd Input: n = 125 Output: Even
A naive approach would be to find all the divisors and then see if the total number of divisors is even or odd.
The time complexity for such a solution would be O(sqrt(n))
The count of divisor: Even
We can observe that the number of divisors is odd only in case of perfect squares. Hence the best solution would be to check if the given number is perfect square or not. If it’s a perfect square, then the number of divisors would be odd, else it’d be even.
The count of divisors of 10 is: Even
Please refer complete article on Check if count of divisors is even or odd for more details!
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.
- C Program to Check if count of divisors is even or odd
- Check if count of even divisors of N is equal to count of odd divisors
- Check if count of divisors is even or odd
- Program to find count of numbers having odd number of divisors in given range
- Java Program for Common Divisors of Two Numbers
- Count Divisors of n in O(n^1/3)
- Check if sum of divisors of two numbers are same
- Count Divisors of Factorial
- Java Program to check Armstrong Number
- Java program to check if a number is prime or not
- Check if the given array contains all the divisors of some integer
- Java Program to Count set bits in an integer
- Java program to count the occurrences of each character
- Count of integers up to N which are non divisors and non coprime with N
- Count total divisors of A or B in a given range
- Count all perfect divisors of a number
- Count of the non-prime divisors of a given number
- Count divisors of n that have at-least one digit common with n
- Count of Fibonacci divisors of a given number
- Count divisors of array multiplication