Timer is Running

Odd Divisors
Submissions: 1   Accuracy:

0%

  Difficulty: Basic   Marks: 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

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: kartik


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.