X

DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
Odd Divisors
Basic Accuracy: 52.43% Submissions: 107 Points: 1

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 are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.


to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Odd Divisors

Output Window