CryptoJones icon

Russian Peasant Algoritm C#

CryptoJones | PRO | 07/31/17 05:00:57 PM UTC | 0 ⭐ | 540 👁️ | Never ⏰ | []
C# |

480 B

|

None

|

0 👍

/

0 👎

        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;
        }

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎