MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / f4

Method f4

src/class098/Code02_BigShow.java:185–204  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

183
184 // 用矩阵快速幂解决斐波那契第n项的问题
185 public static void f4() {
186 // 0 1 1 2 3 5 8 13 21 34...
187 // 0 1 2 3 4 5 6 7 8 9
188 int[][] start = { { 1, 0 } };
189 int[][] m = {
190 { 1, 1 },
191 { 1, 0 }
192 };
193 int[][] a = multiply(start, power(m, 1));
194 print(a);
195 System.out.println("======");
196 int[][] b = multiply(start, power(m, 2));
197 print(b);
198 System.out.println("======");
199 int[][] c = multiply(start, power(m, 3));
200 print(c);
201 System.out.println("======");
202 int[][] d = multiply(start, power(m, 4));
203 print(d);
204 }
205
206}

Callers 1

mainMethod · 0.95

Calls 4

multiplyMethod · 0.95
powerMethod · 0.95
printMethod · 0.95
printlnMethod · 0.45

Tested by

no test coverage detected