mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-11 06:26:05 +08:00
format binary_exponent.cpp
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
///C++ Program to find Binary Exponent recursively.
|
||||
/// C++ Program to find Binary Exponent recursively.
|
||||
|
||||
#include<iostream>
|
||||
/*
|
||||
@@ -8,7 +8,7 @@
|
||||
* (instead of O(n) multiplications required by the naive approach).
|
||||
*/
|
||||
|
||||
///Function to calculate exponent in O(log(n)) using binary exponent.
|
||||
/// Function to calculate exponent in O(log(n)) using binary exponent.
|
||||
int binExpo(int a,int b) {
|
||||
if (b == 0) return 1;
|
||||
int res = binExpo(a,b/2);
|
||||
@@ -20,7 +20,7 @@ int main() {
|
||||
int a,b;
|
||||
/// Give two nos as a^b (where '^' denotes power exponent operation)
|
||||
std::cin >> a >> b;
|
||||
///Result of a^b
|
||||
/// Result of a^b
|
||||
std::cout << binExpo(a,b) << std::endl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user