12-20-2018, 02:29 PM

Original blog post: https://edspi31415.blogspot.com/2018/12/...nacci.html

This program is the request of John Cvetan. I thank you for your suggestion.

To generate the Fibonacci triangle,

1. Let r the row and c be the column with

f_0,0 = 1

f_1,0 = 1

f_1,1 = 1

f_2,1 = 1

2. Each row will be determined by adding the last two terms going diagonally. You can use one of two formulas:

f_r,c = f_r-1,c + f_r-2,c

f_r,c = f_r-1,c-1 + f_r-1,c-2

The Program FIBMAT

FIBMAT generates a Fibonacci triangle in matrix form. It's the result is a triangle that is "tilted". n will need to be 3 or greater.

The Program FIBTRI

This is a visual program for Fibonacci Triangle.

FIBTRI(n) generates a visual Fibonacci Triangle - although I don't recommend going beyond 12 rows due to the constraints of the screen. I used the small font for the rows.

HP Prime Program FIBTRI

Source:

Hosoya, Haruo. "Fibonacci Triangle" Ochanomizu University, Tokyo, Japan. 1976. https://www.fq.math.ca/Scanned/14-2/hosoya.pdf

This program is the request of John Cvetan. I thank you for your suggestion.

To generate the Fibonacci triangle,

1. Let r the row and c be the column with

f_0,0 = 1

f_1,0 = 1

f_1,1 = 1

f_2,1 = 1

2. Each row will be determined by adding the last two terms going diagonally. You can use one of two formulas:

f_r,c = f_r-1,c + f_r-2,c

f_r,c = f_r-1,c-1 + f_r-1,c-2

The Program FIBMAT

FIBMAT generates a Fibonacci triangle in matrix form. It's the result is a triangle that is "tilted". n will need to be 3 or greater.

Code:

`EXPORT FIBMAT(n)`

BEGIN

// Fibonacci "triangle" in

// matrix form

// 2018-12-17 EWS

LOCAL M1,k;

M1:=MAKEMAT(0,n+1,n+1);

M1(1,1):=1;

M1(2,1):=1;

M1(2,2):=1;

FOR k FROM 3 TO n+1 DO

M1(k):=row(M1,k-1)+row(M1,k-2);

M1(k,k):=M1(k-1,k-1)+M1(k-2,k-2);

END;

RETURN M1;

END;

The Program FIBTRI

This is a visual program for Fibonacci Triangle.

FIBTRI(n) generates a visual Fibonacci Triangle - although I don't recommend going beyond 12 rows due to the constraints of the screen. I used the small font for the rows.

HP Prime Program FIBTRI

Code:

EXPORT FIBTRI(n)

BEGIN

// Fibonacci triangle

// 2018-12-17 EWS

LOCAL M1,k;

M1:=MAKEMAT(0,n+1,n+1);

M1(1,1):=1;

M1(2,1):=1;

M1(2,2):=1;

FOR k FROM 3 TO n+1 DO

M1(k):=row(M1,k-1)+row(M1,k-2);

M1(k,k):=M1(k-1,k-1)+M1(k-2,k-2);

END;

RECT();

LOCAL s;

FOR k FROM 1 TO n+1 DO

s:=STRING(SUB(row(M1,k),1,k));

IF k≤6 THEN

TEXTOUT_P(s,

140-5.5*(k-1),(k-1)*15,2);

END;

IF k>6 AND k≤11 THEN

TEXTOUT_P(s,

140-8*(k-1),(k-1)*15,2);

END;

IF k>11 THEN

TEXTOUT_P(s,

140-11.5*(k-1),(k-1)*15,2);

END;

END;

WAIT(0);

END;

Hosoya, Haruo. "Fibonacci Triangle" Ochanomizu University, Tokyo, Japan. 1976. https://www.fq.math.ca/Scanned/14-2/hosoya.pdf