- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

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

# Java Program to get number of elements with odd factors in given range

To get number of elements with odd factors in given range, the Java code is as follows −

## Example

import java.io.*; import java.util.*; import java.lang.*; public class Demo{ public static int square_count(int low_range, int high_range){ return (int)Math.pow((double)high_range,0.5) - (int)Math.pow((double)low_range-1,0.5); } public static void main (String[] args){ int low_range = 55, high_range = 1000; System.out.print("The number of values with odd factors between a given range of numbers is : " + square_count(low_range, high_range)); } }

## Output

The number of values with odd factors between a given range of numbers is : 24

A class named Demo contains a function named ‘square_count’. This function is defined by passing two integer values as parameters. It returns the number of elements that have odd factors given a specific range. This is done by using the math function ‘pow’. In the main function, the lower range and higher range values are defined and the function ‘square_count’ is called with the lower and higher range values. The relevant message is displayed on the console.

- Related Questions & Answers
- Python Program for Number of elements with odd factors in the given range
- Number of indexes with equal elements in given range in C++
- C Program for Find sum of odd factors of a number?
- C++ program for Find sum of odd factors of a number
- Python Program for Find sum of odd factors of a number
- Program to find count of numbers having odd number of divisors in given range in C++
- Python Program to replace list elements within a range with a given number
- Java Program to Display Factors of a Number
- C++ program to find numbers with K odd divisors in a given range
- Golang Program to Print Odd Numbers Within a Given Range
- Count number of smallest elements in given range in C++
- Find sum of odd factors of a number using C++.
- Java program to find whether given number is even or odd
- PHP program to find the sum of odd numbers within a given range
- C++ Program to calculate the number of odd days in given number of years

Advertisements