#include <stdio.h>

int exponent_fast(int x,int n)
{
	int result=1,m,sample=x;
	m=n;
	while(m>0)
	{
		while( m%2 == 0)
		{
			sample =sample *sample;
			m/=2;
			if(m==0)break;
		}
		--m;
		result = result * sample;
	}
	return result;
}
int main(void) {
	// your code goes here
	printf("%d\n",exponent_fast(2,4));
	printf("%d\n",exponent_fast(2,3));
	printf("%d\n",exponent_fast(3,4));
	printf("%d\n",exponent_fast(3,3));
	return 0;
}
