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