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.
Be the first one to answer
Add answer anonymously...
Mr Cooper Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter