daily pastebin goal
67%
SHARE
TWEET

Russian Peasant Algoritm C#

CryptoJones Jul 31st, 2017 41 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         public static int RussianPeasantAlgorithm(int a, int b){
  2.             int z = 0;
  3.             while (a > 0){
  4.                     if (a % 2 == 1){ z = z + b;}
  5.                 b = b << 1;
  6.                 a = a >> 1;
  7.             }
  8.             return z;
  9.         }
  10.  
  11.         public static int NormalMultiplication(int a, int b){
  12.             int z = 0;
  13.             while (a > 0){
  14.                 z = z + b;
  15.                 a = a - 1;
  16.             }
  17.             return z;
  18.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top