← RoseCode

ROSECODE 158

Programming exercise - Counting

Philippe_57721 · Programming ·

Let the following function


function(n)
begin
	count = 0
	for i in 1 to n
		for j in (i+1) to n
			if 1 = GCD(i,j)
				count = count+1
	return count				
end


What is function(123456789)
You are given: function(10^5) = 3039650753

[My timing: 80 sec]
P.S: I slightly changed the parameter (and the answer) as the original solution might be easily found on the web.