Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Sage provides fibonacci to access elements of the Fibonacci sequence.

So, you could do things like

sage: [fibonacci(j) for j in (0 .. 12)]
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
sage: [fibonacci(j) for j in (1, 2, 4, 7, 11, 16)]
[1, 1, 3, 13, 89, 987]
click to hide/show revision 2
No.2 Revision

Sage provides fibonacci to access elements of the Fibonacci sequence.

This can be combined with basic list comprehension and sum.

So, you could do things like

sage: [fibonacci(j) for j in (0 .. 12)]
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
sage: sum(fibonacci(j) for j in (0 .. 12))
376

or

sage: [fibonacci(j) for j in (1, 2, 4, 7, 11, 16)]
[1, 1, 3, 13, 89, 987]
sage: sum(fibonacci(j) for j in (1, 2, 4, 7, 11, 16))
1094
click to hide/show revision 3
No.3 Revision

Sage provides fibonacci to access elements of the Fibonacci sequence.

This can be combined with basic list comprehension and sum.

So, you could do things likelike listing or summing consecutive terms:

sage: [fibonacci(j) for j in (0 .. 12)]
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
sage: sum(fibonacci(j) for j in (0 .. 12))
376

oror non-consecutive terms:

sage: [fibonacci(j) for j in (1, 2, 4, 7, 11, 16)]
[1, 1, 3, 13, 89, 987]
sage: sum(fibonacci(j) for j in (1, 2, 4, 7, 11, 16))
1094
click to hide/show revision 4
No.4 Revision

Sage provides fibonacci to access elements of the Fibonacci sequence.

This can be combined with basic list comprehension and sum.

So, you could do things like listing or summing consecutive terms:

sage: [fibonacci(j) for j in (0 .. 12)]
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
sage: sum(fibonacci(j) for j in (0 .. 12))
376

or non-consecutive terms:

sage: [fibonacci(j) for j in (1, 2, 4, 7, 11, 16)]
[1, 1, 3, 13, 89, 987]
sage: sum(fibonacci(j) for j in (1, 2, 4, 7, 11, 16))
1094

It seems the indices you are interested about are of the form (n2+n+2)/2

sage: [(n^2 + n + 2)//2 for n in range(10)]
[1, 2, 4, 7, 11, 16, 22, 29, 37, 46]

so here are the terms of the Fibonacci sequence for these indices:

sage: [fibonacci((n^2 + n + 2)//2) for n in range(10)]
[1, 1, 3, 13, 89, 987, 17711, 514229, 24157817, 1836311903]

and here is their sum them up to some point:

sage: sum(fibonacci((n^2 + n + 2)//2) for n in range(10))
1861002754

and here is how this sum evolves when you push it further and further:

sage: [sum(fibonacci((j^2 + j + 2)//2) for j in range(n)) for n in range(10)]
[0, 1, 2, 5, 18, 107, 1094, 18805, 533034, 24690851]

Since all the Fibonacci numbers are at least one, if you add infinitely many of them, the sum will tend to infinity.