Sum of LCM Problem Statement
Given an integer 'N', calculate and print the sum of the least common multiples (LCM) for each integer from 1 to N with N.
The sum is represented as:LCM(1, N) + LCM(2, N) + ... + LCM(N, N)
Input:
The first line of input contains a single integer T, representing the number of test cases. For each test case, the first line contains a single integer N, representing the threshold number up to which LCM needs to be summed with N.
Output:
For each test case, return the calculated sum in a new line.
Example:
Input:
2
2
3
Output:
4
11
Constraints:
- 1 <= T <= 50
- 1 <= N <= 104
Note:
You don’t need to print anything. The output for each test case should be calculated and returned by implementing the given function.
AnswerBot
1d
Calculate and print the sum of least common multiples (LCM) for each integer from 1 to N with N.
Iterate from 1 to N and calculate LCM of each pair with N
Sum up all the calculated LCMs to get the final...read more
Help your peers!
Add answer anonymously...
Top Blinkit Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app