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 number with N
Sum up all the calculated LCMs to get the fin...read more
Help your peers!
Add answer anonymously...
Google Software Developer Intern interview questions & answers
A Software Developer Intern was asked Q. Majority Element - II Problem Statement Given an array/list ARR of integers with...read more
A Software Developer Intern was asked Q. Consecutive Elements Given an array arr of N non-negative integers, determine wh...read more
A Software Developer Intern was asked Q. Minimum Removals Problem Statement Given an integer array ARR of size N and an i...read more
Popular interview questions of Software Developer Intern
A Software Developer Intern was asked Q1. Majority Element - II Problem Statement Given an array/list ARR of integers with...read more
A Software Developer Intern was asked Q2. Consecutive Elements Given an array arr of N non-negative integers, determine wh...read more
A Software Developer Intern was asked Q3. Minimum Removals Problem Statement Given an integer array ARR of size N and an i...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

