5^65537
時間を乗算する代わりに計算したい5
65537
場合は、 を実行することをお勧めします((5^2)^16)*5
。これにより、16 回の 2 乗と 1 回の乗算が行われます。
しかし、私の質問は、非常に大きな数を 2 乗することで 2 乗回数を補っているのではないでしょうか? コンピューターの基本的なビット乗算に進むと、これはどのように高速になりますか。
コメントを読んだ後、私はこの疑問を持っています:
How is the cost of each multiplication not dependant on the size. because when
multiplying the number of bits of the multiplier will increase and this will increase the
number of additions and the number of left shifts.