program sample8a; type seki=^sobeki; sobeki=record sosuu,beki:integer; next :seki end; var n:integer; b:seki; hitotsume:boolean; function bunkai(x:integer):seki; var p,e,m:integer; r,s:seki; begin new(r); bunkai:=r; p:=1; m:=trunc(sqrt(x)); repeat p:=p+1; e:=0; while (x mod p)=0 do begin x:=(x div p); e:=e+1 end; if e>0 then begin r^.sosuu:=p; r^.beki:=e; if x=1 then r^.next:=nil else begin new(s); r^.next:=s; r:=s; m:=trunc(sqrt(x)) end end; until (x=1) or (p>m); if x>1 then begin r^.sosuu:=x; r^.beki:=1; r^.next:=nil; end; end; begin repeat writeln; write('2 以上の自然数を入力してください( 0 ならば終了): '); readln(n); if n>1 then begin write(n:1,' = '); b:=bunkai(n); hitotsume:=true; while b<>nil do begin if hitotsume=false then write(' × '); write(b^.sosuu:1); if b^.beki>1 then write('^',b^.beki:1); hitotsume:=false; b:=b^.next end; writeln end; until n=0 end.