I invite you to consider the issue.
Consider a number series consisting of even numbers.
Let's decompose sequentially even numbers in a triangle, starting from 0 at the top and on each new line we will add one element.
- 0
- 2 4
- 6 8 10
- 12 14 16 18
- 20 22 24 26 28 n. ... n+1. ...... And so on ad infinitum
I think the layout is clear.
The question is as follows.
It is required to find the sum of the specified string and all elements of .
For instance:
Given: the number X is the row number
Find:
1) all elements from this row
2) the sum of these elements
Bonus:
Given: the number A is a random number from 0 to infinity
Find:
1) check if the number is even
2) if the given number is even then find
on which line this number is located
Here is such a problem for warming up the brain.
I would be glad to hear your opinion, and it is interesting to see interesting solutions.
Sincerely yours @vova2kms
Top comments (0)