- Related Questions & Answers
- Java Program to check if count of divisors is even or odd
- Check if count of divisors is even or odd in Python
- Python Program for Check if the count of divisors is even or odd
- PHP program to check if the total number of divisors of a number is even or odd
- C++ Program to Check Whether Number is Even or Odd
- How to Check if a Number is Odd or Even using Python?
- C# Program to check if a number is Positive, Negative, Odd, Even, Zero
- 8085 program to check whether the given number is even or odd
- Program to check if a number is Positive, Negative, Odd, Even, Zero?
- How to determine if a number is odd or even in JavaScript?
- Java program to find whether given number is even or odd
- Program to find count of numbers having odd number of divisors in given range in C++
- Check whether given floating point number is even or odd in Python
- Check whether product of 'n' numbers is even or odd in Python
- Check whether the length of given linked list is Even or Odd in Python

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Given a number “n” as an input, this program is to find the total number of divisors of n is even or odd. An even number is an integer that is exactly divisible by 2. Example: 0, 8, -24

An odd number is an integer that is not exactly divisible by 2. Example: 1, 7, -11, 15

Input: 10 Output: Even

Find all the divisors of the n and then check if the total number of divisors are even or odd. To do this find all divisor and count the number and then divide this number by 2 to check if it is even or odd.

#include <iostream> #include <math.h> using namespace std; int main() { int n=10; int count = 0; for (int i = 1; i <= sqrt(n) + 1; i++) { if (n % i == 0) count += (n / i == i) ? 1 : 2; } if (count % 2 == 0) printf("Even\n"); else printf("Odd\n"); return 0; }

Advertisements