We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 53297f7 commit 3ec91f3Copy full SHA for 3ec91f3
project_euler/problem_122/sol1.py
@@ -8,20 +8,21 @@
8
n x n x ... x n = n^15.
9
10
But using a "binary" method you can compute it in six multiplications:
11
+
12
n x n = n^2
13
n^2 x n^2 = n^4
14
n^4 x n^4 = n^8
15
n^8 x n^4 = n^12
16
n^12 x n^2 = n^14
17
n^14 x n = n^15
18
-<However it is yet possible to compute it in only five multiplications:
19
+However it is yet possible to compute it in only five multiplications:
20
-n x n = n^2
21
-n^2 x n = n^3
22
-n^3 x n^3 = n^6
23
-n^6 x n^6 = n^{12}
24
-n^12 x n^3 = n^{15}
+ n x n = n^2
+ n^2 x n = n^3
+ n^3 x n^3 = n^6
+ n^6 x n^6 = n^12
25
+ n^12 x n^3 = n^15
26
27
We shall define m(k) to be the minimum number of multiplications to compute n^k; for example m(15) = 5.
28
0 commit comments