/*************************************************************
Program to multiply two numbers using Russian peasant method
*************************************************************/
#include <stdio.h>
int main()
{
int a, b, result = 0, m, n;
printf("Enter two numbers: \n");
scanf("%d %d", &a, &b);
m = a;
n = b;
while(n > 0)
{
if(n % 2 != 0)
{
result += m;
}
m *= 2; // double the first number
n /= 2; // half the second number
}
printf("%d * %d = %d", a, b, result);
return 0;
}