Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int RussianPeasantAlgorithm(int a, int b){
- int z = 0;
- while (a > 0){
- if (a % 2 == 1){ z = z + b;}
- b = b << 1;
- a = a >> 1;
- }
- return z;
- }
- public static int NormalMultiplication(int a, int b){
- int z = 0;
- while (a > 0){
- z = z + b;
- a = a - 1;
- }
- return z;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement