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
4mo
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...
Blinkit Software Developer Intern interview questions & answers
A Software Developer Intern was asked Q. Top View of Binary Tree Given a binary tree of integers, the task is to return t...read more
A Software Developer Intern was asked Q. Maximum Possible Time Problem Statement Given an array ARR consisting of exactly...read more
A Software Developer Intern was asked Q. Sum of LCM Problem Statement Given an integer 'N', calculate and print the sum o...read more
Popular interview questions of Software Developer Intern
A Software Developer Intern was asked Q1. Maximum Possible Time Problem Statement Given an array ARR consisting of exactly...read more
A Software Developer Intern was asked Q2. Sum of LCM Problem Statement Given an integer 'N', calculate and print the sum o...read more
A Software Developer Intern was asked Q3. Vertical Order Traversal Problem Statement Given a binary tree, return the verti...read more
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

