Function f(x:real; k:integer):real;
begin
if k=1
then f:=x
else if k mod 2=0
then f:=sqr(f(x,k div 2))
else f:=sqr(f(x,(k-1) div 2))*x;
end;
var a:real; n:integer;
begin
write('a = ');
readln(a);
write('n = ');
readln(n);
writeln(a,'^',n,' = ',f(a,n));
end.
Пример:
a = 2
n = 10
2^10 = 1024