diff --git a/cpp/algorithms/ppbra.cpp b/cpp/algorithms/ppbra.cpp new file mode 100644 index 000000000..b83e507e8 --- /dev/null +++ b/cpp/algorithms/ppbra.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; +typedef long long ll; +ll Modular_Exponentiation(ll A,ll B,ll MOD)// computes (A^B)%MOD +{ + ll ans=1; + A=A%MOD; + while(B>0) + { + if(B&1) ans=(ans*A)%MOD; + B=B>>1; + A=(A*A)%MOD; + } + return ans; +} +int main() +{ + cout<<"Enter number, power and MOD\n"; + ll a,b,c; + cin>>a>>b>>c; + cout<