program task;
var
n, i, power, copy: integer;
flag: boolean;
begin
readln( n );
copy := n;
i := 2;
flag := false;
while copy <> 1 do begin
while copy mod i <> 0 do
i := i + 1;
power := 0;
while ( copy mod i = 0 ) do begin
copy := copy div i;
power := power + 1;
end;
if flag then write( '*' )
else flag := true;
if power > 1 then
write( i, '^', power )
else
write( i );
i := i + 1;
end;
writeln;
end.
переведите на питон
power = 0
n = int(input())
copy = n
i = 2
flag = False
while copy != 1:
while copy % i != 0: i += 1
power = 0
while copy % i == 0:
copy //= i
power += 1
if flag: print('*', end = '')
else: flag = True
if power > 1: print(str(i) + '^' + str(power), end = '')
else: print(i, end = '')
i += 1