n-step Fibonacci sequences
A text file for the 2-step to 10-step Fibonacci sequences from number 1 to 200
fib-nStep-2-10-200-results.txt
Another text file for the 2-step to 10-step Fibonacci and Lucas numbers from 1 to 100. Lucas numbers uses the same matrix for the Fibonacci numbers. Pari GP code in the text.
R code to calculate the n-step Fibonacci number. Uses a matrix solution. coming shortly. This code is for computer use only and requires the gmp library for precision.
\\ pari/gp code for n-step Fibonacci number
number=1000; \\nStep Fibonacci number
nStep=2; \\nStep. do NOT change for regular Fibonacci
\\\do not change below
\\build and populate matrix
A=matrix(nStep,nStep);
r1=vector(nStep,i,1);
A[1,]=r1;
for(i=2,nStep,A[i,(i-1)]=1); \\diagonal starts at A[2,1]
B=A^number;
fibNumber=B[1,nStep];
print(fibNumber)
print(#digits(fibNumber))
\\ pari/gp code for a n-step Fibonacci number range starting at 1
number=100; \\1 to number range
nStep=2; \\nStep - \\only change for 3 step or higher
nth=7; \\nth n-step Fibonacci number
\\\\\\\\
col=nStep;
\\build and populate matrix
A=matrix(nStep,col);
r1=vector(nStep,i,1);
A[1,]=r1;
for(i=2,nStep,A[i,(i-1)]=1); \\diagonal starts at A[2,1]
prob=vector(number);
seq1c=Col([1..number]);\\Column vector
for(T=1,number,result=A^T;prob[T]=result[1,nStep])
\\print(prob[nth]) \\uncomment to see nth number
a=Col(prob);
x=matconcat([seq1c,a]);
print(x)