
Asked in Quikr
GCD Sum Problem Statement
Given an integer 'N', the task is to find the sum of the greatest common divisor (GCD) of all pairs (i, j) such that 1 <= i < j <= N.
Input:
T
(the number of test cases)
For each test case:N
(an integer)
Output:
An integer representing the sum of GCD of all pairs of numbers from 1 to N.
A new line for each test case.
Example:
Input:
T = 1
N = 3
Output:
3
Explanation:
For N = 3, the pairs are (1, 2), (1, 3), and (2, 3). The GCDs are 1, 1, and 1 respectively; sum is 3.
Constraints:
1 <= T <= 5
1 <= N <= 5000
Note:
You do not need to perform input/output operations as it has been handled. Implement the function and return the result.
Be the first one to answer
Add answer anonymously...
Interview Questions Asked to Software Developer Intern at Other Companies
Top Skill-Based Questions for Quikr Software Developer Intern
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Operating Systems Interview Questions and Answers
250 Questions
System Design Interview Questions and Answers
250 Questions
C++ Interview Questions and Answers
150 Questions
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

