- Related Questions & Answers
- Add minimum number to an array so that the sum becomes even in C programming
- C Program for Tower of Hanoi
- C++ Program for Dijkstra’s shortest path algorithm?
- C/C++ Program for nth Catalan Number?
- C Program to Multiply two Floating Point Numbers?
- C program to find the length of a string?
- C Program to Check if all digits of a number divide it
- C Program to Check if a Given String is a Palindrome?
- Concatenate a string given number of times in C++ programming
- Write a program to Delete a Tree in C programming
- Write a C program to print “ Tutorials Point ” without using a semicolon
- Superperfect Number in C programming
- Sum of the nodes of a Singly Linked List in C Program
- Sum of first n natural numbers in C Program
- HTML DOM Input Number value Property

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

In this article, we will learn about the solution to the problem statement given below.

**Problem statement **− We are given a range, we need to find the number of odd factors in the range.

As we all know that all perfect squares have an odd number of factors in a range. So here we will compute a number of perfect squares.

As m and n both are inclusive, so to avoid error in case of n being a perfect square we take n-1 in the formulae.

Now let’s see the implementation below−

# count function def count(n, m): return int(m**0.5) - int((n-1)**0.5) # main n = 25 m = 400 print("Number of odd squares are: ", count(n, m))

Number of odd squares are: 16

All the variables and functions are declared in the global scope as shown in the figure above.

In this article, we have learned how we can find the number of elements with odd factors in a given range.

Advertisements