mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-09 21:47:07 +08:00
Update math/binary_exponent.cpp
Co-Authored-By: John Law <johnlaw.po@gmail.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
#include<iostream>
|
||||
/*
|
||||
* Calculating a^b in O(log(b)) by converting b in binary no.
|
||||
* Calculate a^b in O(log(b)) by converting b to a binary number
|
||||
* Binary exponentiation (also known as exponentiation by squaring)
|
||||
* is a trick which allows to calculate an using only O(logn) multiplications
|
||||
* (instead of O(n) multiplications required by the naive approach).
|
||||
|
||||
Reference in New Issue
Block a user