void evenPower( int level, a, n; var int result; )
	begin
		int result1;
		if n == 0 then
			result = 1;
		else
			power( level + 1, a, n / 2, result1 );
			result = result1 * result1;
		end
	end

void oddPower( int level, a, n; var int result; )
	begin
		int result1;
		if n == 1 then
			result = a;
		else
			power( level + 1, a, n / 2, result1 );
			result = a * result1 * result1;
		end
	end

void power( int level, a, n; var int result; ) 
	begin
		if n / 2 * 2 == n then
			evenPower( level + 1, a, n, result );
		else
			oddPower( level + 1, a, n, result );
		end
	end

int a = 3;
int n = 2;
int result;
power( 0, a, n, result );
println( result );
