← Back to challenges

Fibonacci Sum

PythonHardalgebramath

Instructions

Knowing that S(n) is the sum of the first n terms in the fibonacci series, and that G(n) is the sum of the first n terms in the "S" series, create a function that returns the value of G(n), for 20000 >= n >= 20.

The entries will be the value of n and the value of A(n).

Series representation:

  • Fibonacci ➞ A(1), A(2), A(3), ..., A(n)
  • S(n) ➞ A(1) + A(2) + A(3) + ... + A(n)
  • G(n) ➞ S(1) + S(2) + S(3) + ... + S(n)

Examples

G (20, 6765) ➞ 46345

G (21, 10946) ➞ 75001

G (80, 23416728348467685) ➞ 160500643816367005

Notes

Consider that the first terms of the fibonacci series are: 1, 1, 2 ...

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.