loading...

re: Daily Challenge #112 - Functions of Integers on the Cartesian Plane VIEW POST

FULL DISCUSSION
 

Elegant challenge. We can notice that f and g are complementary to each other. We can draw the grid for f and g and notice, that sum of these grids is equal to sum of the gride of size n*n with (n+1) value is each cell. So the sum of f and g is equal to n*n*(n+1). The sum h is also equal to f + g.

fun fghSum(n: Long) = n * n * (n + 1) * 2
code of conduct - report abuse