diff --git a/Number Theory/Fast_Multiply.cpp b/Number Theory/Fast_Multiply.cpp index d38b6c1..d17cf5a 100644 --- a/Number Theory/Fast_Multiply.cpp +++ b/Number Theory/Fast_Multiply.cpp @@ -1,9 +1,19 @@ -int fast_multiply(int a,int b,int c){ - int res=0; - while(b){ - if(b&1)res+=a,res%=c; - a+=a,a%=c; - b>>=1; - } - return res; -} \ No newline at end of file +#include + +using namespace std; + +int binary_multiplication(int a , int b,int M=(int)1e9+7){ + int res = 0; + while( b ){ + if( b&1 ) res += a , res %= M; + a = 2 * a ; a %= M: + b >>= 1; + } + + return res; +} + +int main(){ + + return 0; +}