ACLS
OPTION DEFINT
DEF F(N)
IF N==1THEN RETURN 1
IF N==2THEN RETURN 1
IF N==3THEN RETURN 2
RETURN F(N-1)+F(N-3)
END
DEF MMUL N,A[],B[],C[]
DIM T1[N,N],T2[N,N]
VAR I,J,K
COPY T1,A:COPY T2,B:FILL C,0
FOR J=0 TO N-1
FOR I=0 TO N-1
FOR K=0 TO N-1
INC C[J,I],T1[J,K]*T2[K,I]
NEXT K
NEXT I
NEXT J
END
DEF MPOW N,A,M,O
VAR I
DIM T[N,N]
COPY T,A:FILL O,0
FOR I=0TO N-1
O[I,I]=1
NEXT I
WHILE M
IF M AND 1 THEN
MMUL N,O,T,O
ENDIF
MMUL N,T,T,T
M=M>>1
WEND
END
DIM A[3,3]
A[0,0]=1
A[0,2]=1
A[1,0]=1
A[2,1]=1
VAR N
INPUT N
MPOW 3,A,N,A
PRINT A[0,0],F(N)