You can try to solve 2 + 4 + 6 + 8 + ... + 2n with the knowledge you already have about 1+2+...+n.Coco wrote:Now Im trying to figure out a way to sum all even (and only even) numbers via some formula, even if input is odd number. So if input is 7 for example the output should be 2+4+6=12. If input is 6,the result should be the same.

There is a hint:

**Spoiler:**show

You can extend the previous solution to define your f(N), distinguishing if N is odd or even.Coco wrote:Now Im trying to figure out a way to sum all even (and only even) numbers via some formula, even if input is odd number.

You can define g(N) = 1 + 3 + ... + N, if N is odd. cause you have f(N) + g(N) = S, and you know what is g and S.Coco wrote:Ratios between sums of even and odd numbers, their progression

Same way defining g(N), if N is even.

Once you have g, you can define h(N) = f(N) / g(N), function of ratios.

You can also define a

_{k}= h(k), for k=1,2,3,... b

_{k}= f(k) - g(k), for k=1,2,3,...