Guess the algorithm

Yesterday I found and programmed a nice little algorithm. I’m not going to tell you (yet) what it does and how its called, but I’ll just show the code:

private int function(int x, int y) {
	int r = 0;
	while(x!=0) {
		if((x&1)==1) {
	return r;

So tell me, what does this do, and what is the algorithm called?


And indeed (it was a simple one) the correct solution is multiplication, and to be specific, Ethiopian or Russian Multiplication.

I’ll probably do more, harder ones, in the future..!