- Related Questions & Answers
- Java Program to check if count of divisors is even or odd
- C Program to Check if count of divisors is even or odd?
- Python Program for Check if the count of divisors is even or odd
- Check if count of divisors is even or odd in Python
- C++ Program to Check Whether Number is Even or Odd
- How to Check if a Number is Odd or Even using Python?
- 8085 program to check whether the given number is even or odd
- Program to check if a number is Positive, Negative, Odd, Even, Zero?
- C# Program to check if a number is Positive, Negative, Odd, Even, Zero
- How to determine if a number is odd or even in JavaScript?
- PHP program to check if a number is prime or not
- Java program to find whether given number is even or odd
- Check if product of digits of a number at even and odd places is equal in Python
- Python Program to Determine Whether a Given Number is Even or Odd Recursively
- Check if a number is divisible by all prime divisors of another number in C++

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

To check if the total number of divisors of a number is even or odd, the code is as follows −

<?php function divisor_count($my_val) { $my_count = 0; for ($i = 1; $i <= sqrt($my_val) + 1; $i++) { if ($my_val % $i == 0) $my_count += ($my_val / $i == $i)? 1 : 2; } if ($my_count % 2 == 0) echo "It is an even number\n"; else echo "It is an odd number\n"; } divisor_count(100); ?>

It is an odd number

A function named ‘divisor_count’ is defined that gives the number of divisors of a given number that is passed as a parameter to the function. Now, each of these divisors is checked to see if it can be completely divided by 2, if yes, it is an even divisor, and otherwise, it is an odd divisor. Relevant message is displayed on the console.

Advertisements