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.
funfghSum(n:Long)=n*n*(n+1)*2
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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.