Re: matrix and fibonacci

2012-03-10 Thread newcomer[bob]
On Friday, 9 March 2012 at 14:07:10 UTC, Timon Gehr wrote: On 03/09/2012 06:50 AM, newcomer[bob] wrote: The following is a matrix implementation of the fibonacci algorithm: int fib(int n) { int M[2][2] = {{1,0},{0,1}} for (int i = 1; i n; i++) M = M * {{1,1},{1,0}} return M[0][0]; }

Re: matrix and fibonacci

2012-03-09 Thread newcomer[bob]
On Friday, 9 March 2012 at 05:50:03 UTC, newcomer[bob] wrote: The following is a matrix implementation of the fibonacci algorithm: int fib(int n) { int M[2][2] = {{1,0},{0,1}} for (int i = 1; i n; i++) M = M * {{1,1},{1,0}} return M[0][0]; } problem is I don't really

Re: matrix and fibonacci

2012-03-09 Thread newcomer[bob]
On Friday, 9 March 2012 at 09:22:47 UTC, newcomer[bob] wrote: On Friday, 9 March 2012 at 05:50:03 UTC, newcomer[bob] wrote: The following is a matrix implementation of the fibonacci algorithm: int fib(int n) { int M[2][2] = {{1,0},{0,1}} for (int i = 1; i n; i++) M = M *

Re: matrix and fibonacci

2012-03-09 Thread Timon Gehr
On 03/09/2012 06:50 AM, newcomer[bob] wrote: The following is a matrix implementation of the fibonacci algorithm: int fib(int n) { int M[2][2] = {{1,0},{0,1}} for (int i = 1; i n; i++) M = M * {{1,1},{1,0}} return M[0][0]; } problem is I don't really understand how matrix multiplication works