m[][]=AlgoritmiMatrici.identita(2);-->it generates the 2x2 identity matrix
AlgoritmiMatrici.prodotto(m,m);-->is the result of the multiplication between m and m
This code should calculate the umteenth number of Fabionacci series, but it alwyas returns 1.
Can anyone help me?
public static int matrice1(int n) { int m[][]=AlgoritmiMatrici.identita(2); potenzamatrice(m, n-1); return m[0][0]; } public static void potenzamatrice(int[][] m, int n) { if(n>1) { potenzamatrice(m, n/2); m=AlgoritmiMatrici.prodotto(m,m); } if(n%2==1) { int a[][]={{1,1},{1,0}}; m=AlgoritmiMatrici.prodotto(m,a); } }