This is more of a mathematical question than a programming one, but we can investigate it more easily with code.
The only relevant feature of the Fibonacci sequence here is the string lengths of the numbers, i.e. their number of digits. Since the Fibonacci sequence has exponential growth, the number of digits increases approximately linearly, because the base-10 logarithm function tells you how many digits it has, and a logarithm is the inverse of an exponential function.
So we can observe the same pattern with strings of linearly-increasing length:
>>> print(*( '8'*i for i in range(70, 89) ))
8888888888888888888888888888888888888888888888888888888888888888888888 888888888
88888888888888888888888888888888888888888888888888888888888888 88888888888888888
8888888888888888888888888888888888888888888888888888888 888888888888888888888888
8888888888888888888888888888888888888888888888888 888888888888888888888888888888
88888888888888888888888888888888888888888888 88888888888888888888888888888888888
8888888888888888888888888888888888888888 888888888888888888888888888888888888888
8888888888888888888888888888888888888 888888888888888888888888888888888888888888
88888888888888888888888888888888888 88888888888888888888888888888888888888888888
8888888888888888888888888888888888 888888888888888888888888888888888888888888888
8888888888888888888888888888888888 888888888888888888888888888888888888888888888
88888888888888888888888888888888888 88888888888888888888888888888888888888888888
8888888888888888888888888888888888888 888888888888888888888888888888888888888888
8888888888888888888888888888888888888888 888888888888888888888888888888888888888
88888888888888888888888888888888888888888888 88888888888888888888888888888888888
8888888888888888888888888888888888888888888888888 888888888888888888888888888888
8888888888888888888888888888888888888888888888888888888 888888888888888888888888
88888888888888888888888888888888888888888888888888888888888888 88888888888888888
8888888888888888888888888888888888888888888888888888888888888888888888 888888888
8888888888888888888888888888888888888888888888888888888888888888888888888888888
The question is then, why do strings of linearly increasing length make this shape?
I've purposely selected the lengths from 70 to 89 because the terminal width is 80, so this puts one "gap" on each line, simplifying the analysis considerably.
- When a string of length 75 runs over the line break, the gap on the next line is 5 spaces further left than the gap on the line above, because 75 is 5 less than 80.
- The next string has length 76, so the gap is 4 spaces further left.
- The next string length is 77, so the gap is 3 spaces further left.
- The next string length is 78, so the gap is 2 spaces further left.
- The next string length is 79, so the gap is 1 space further left.
- The next string length is 80, so the gap is directly underneath the gap on the line above - 0 spaces further left.
- The next string length is 81, so the gap is 1 space further right.
- The next string length is 82, so the gap is 2 spaces further right.
- ...and so on.
Notice the simple pattern: because the string gets longer by 1 each time, the relative offset of the gap changes by 1 on each line. This is a bit like a differential equation: d(gap position) / d(line number)
is a linear function of the line number, so we can find the absolute offset of the gap by integrating: gap position
is a quadratic function of the line number. That means the shape is a parabola (not an ellipse).
A mildly amusing consequence is that if you tune the string width to be near the terminal width, you can draw an integral of any function you like. Here's the integral of the sign function, which looks like abs(x)
as expected:
>>> def sign(x):
... return -1 if x < 0 else 1 if x > 0 else 0
...
>>> print(*( '8'*(79 + 5*sign(i)) for i in range(-10, 10) ))
88888888888888888888888888888888888888888888888888888888888888888888888888 88888
888888888888888888888888888888888888888888888888888888888888888888888 8888888888
8888888888888888888888888888888888888888888888888888888888888888 888888888888888
88888888888888888888888888888888888888888888888888888888888 88888888888888888888
888888888888888888888888888888888888888888888888888888 8888888888888888888888888
8888888888888888888888888888888888888888888888888 888888888888888888888888888888
88888888888888888888888888888888888888888888 88888888888888888888888888888888888
888888888888888888888888888888888888888 8888888888888888888888888888888888888888
8888888888888888888888888888888888 888888888888888888888888888888888888888888888
88888888888888888888888888888 88888888888888888888888888888888888888888888888888
88888888888888888888888888888 88888888888888888888888888888888888888888888888888
8888888888888888888888888888888888 888888888888888888888888888888888888888888888
888888888888888888888888888888888888888 8888888888888888888888888888888888888888
88888888888888888888888888888888888888888888 88888888888888888888888888888888888
8888888888888888888888888888888888888888888888888 888888888888888888888888888888
888888888888888888888888888888888888888888888888888888 8888888888888888888888888
88888888888888888888888888888888888888888888888888888888888 88888888888888888888
8888888888888888888888888888888888888888888888888888888888888888 888888888888888
888888888888888888888888888888888888888888888888888888888888888888888 8888888888
88888888888888888888888888888888888888888888888888888888888888888888888888