##
Summation of GCD of all the pairs up to N
March 11, 2017

Given a number N, find sum of all GCDs that can be formed by selecting all the pairs from 1 to N. Input : 4 Output : 7 Explanation: Numbers from 1 to 4 are: 1, 2, 3, 4 Result = gcd(1,2) + gcd(1,3) + gcd(1,4) + gcd(2,3) + gcd(2,4) + gcd(3,4) = 1 +… Read More »