There is a ladder in which there is 1 step less on each next level, for example, here’s what a ladder of length 4 looks like with a total of 10 steps:

X
Xx
XXX
Xxxx

And, what is even more interesting, is there a way to derive formulas if a pattern is visible?

    2 answers 2

    Typical arithmetic progression . Class 8, or something ...

    1+2+3+...+n = n(n+1)/2 

    If you see a pattern, then it must not be deduced, but proved - by the method of mathematical induction , for example ...

    • Not yet. 9th grade. Thank. - Egor Moroz
    • 3
      Yes, there are no problems, so soon :) About Gauss you did not tell? as the teacher asked to calculate the sum of numbers from 1 to 100, to which the lad noticed that it was 50 pairs: 1 + 100, 2 + 99, 3 + 98 and so on, and everyone is equal to 101 ... :) So it is here. .. - Harry

    In your case: a(i+1) = a(i) + 1 . You want to find the sum: sum(a(i), i=1..n) . That is, knowing the recurrence formula for a sequence, you can find a closed formula for the sum:

      n ___ β•² β•² nβ‹…(n + 1) β•± i = ───────── β•± 2 β€Ύβ€Ύβ€Ύ i = 1 

    The formula can help find sympy (or another symbolic computing system):

     >>> from sympy import Function, Sum, rsolve >>> from sympy.abc import i, n >>> a = Function('a') >>> rsolve(a(i+1)-a(i)-1, a(i), {a(1):1}) i >>> Sum(i, (i, 1, n)).doit() 2 nn ── + ─ 2 2 

    Although in such trivial cases, it can and brute force - this demonstrates the general technique, which can in other cases come in handy. More examples: