Sum of divisors
Basic Accuracy: 67.01% Submissions: 777 Points: 1

Given a natural number n, calculate sum of all its proper divisors. A proper divisor of a natural number is the divisor that is strictly less than the number.

Example 1:

Input: n = 10
Output: 8 
Explanation: Proper divisors 1 + 2 + 5 = 8. 

Example 2:

Input: n = 6
Output: 6
Explanation: Proper divisors 1 + 2 + 3 = 6. 

Your Task:  
You dont need to read input or print anything. Complete the function divSum() which takes n as input parameter and returns sum of proper divisors of n.

Expected Time Complexity: O(sqrt(n))
Expected Auxiliary Space: O(1)

2<= 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.


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


All Submissions

My Submissions:

Login to access your submissions.

Sum of divisors

Output Window