DAYS
HOUR
MINS
SEC
Error
Given a natural number N, find the count of numbers from 1 to N that have an odd number of divisors.
Example 1:
Input: N = 1 Output: 1 Explanation: 1 has only one divisor {1}.
Example 2:
Input: N = 4 Output: 2 Explanation: 4 has an odd number of divisors {1, 2, 4}.
Your Task:
You don't need to read input or print anything. Your task is to complete the function oddNumberOfDivisor() which takes an integer N and returns the count of numbers from 1 to n that have an odd number of divisors.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
1 <= N <= 106
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes