Bueno pues supongo que es el mismo
algoritmo.
Y aquí dicho algoritmo en Delphi:
Código:
function ExpRapida(x, n: Integer): Cardinal;
begin
if n = 1 then
Result := x
else if (n mod 2 = 0) then
Result := ExpRapida(x*x, n div 2)
else if ((n mod 2) mod 2 <> 0) then
Result := (x * ExpRapida(x*x, (n-1) div 2));
end;
Espero te sirva de algo.