Welcome to the daily solving of our PROBLEM OF THE DAY with Siddhartha Hazra. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Maths but will also help you build up problem-solving skills.
In this problem, we are given, a positive integer N., The task is to find the value of summation of F(i) ranging from 1 to n, where function F(i) for the number i is defined as the sum of all divisors of i.
Example :
Input:
N = 4
Output:
15
Explanation:
F(1) = 1
F(2) = 1 + 2 = 3
F(3) = 1 + 3 = 4
F(4) = 1 + 2 + 4 = 7
ans = F(1) + F(2) + F(3) + F(4)
= 1 + 3 + 4 + 7
= 15
Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/sum-of-all-divisors-from-1-to-n4738/1
Solution Function Link: https://ide.geeksforgeeks.org/online-cpp-compiler/1b3af616-360a-46b8-a2f5-e5fdc1a7192b