- 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

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

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)); } }

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?
- Python Program for Find sum of odd factors of a number
- C++ 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
- C++ program to find numbers with K odd divisors in a given range
- Count number of smallest elements in given range in C++
- Golang Program to Print Odd Numbers Within a Given Range
- 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
- Java Program to find minimum sum of factors of a number

Advertisements