
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
Java Program to check if count of divisors is even or odd
To check if the count of divisors is even or odd, the Java code is as follows −
Example
import java.io.*; import java.math.*; public class Demo{ static void divisor_count(int n_val){ int root_val = (int)(Math.sqrt(n_val)); if (root_val * root_val == n_val){ System.out.println("The number of divisors is an odd number"); }else{ System.out.println("The number of divisors is an even number"); } } public static void main(String args[]) throws IOException{ divisor_count(25); } }
Output
The number of divisors is an odd number
A class named Demo contains a function named ‘divisor_count’, that checks if the number of divisors of the specific number is an even value or an odd number. In the main function, the ‘divisor_count’ is called with a value defined. Relevant message is displayed on the console.
- Related Articles
- 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
- PHP program to check if the total number of divisors of a number is even or odd
- Java Program to Check Whether a Number is Even or Odd
- C++ Program to Check Whether Number is Even or Odd
- Java Menu Driven Program to Check Positive Negative or Odd Even Number
- How to Check if a Number is Odd or Even using Python?
- 8085 program to check whether the given number is even or odd
- Java program to find whether 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
- Check Average of Odd Elements or Even Elements are Greater in Java
- Check if the n-th term is odd or even in a Fibonacci like sequence
- Find if sum of odd or even array elements are smaller in Java

Advertisements