knfactor:=proc(N)

local p,d,n,k,t,j,q,r;

p:=array(1..100);
#a1

t:=0; k:=0; n:=N;d:=2;
while n<> 1 do
 r:= n mod d;
 q:= (n - r)/d;
 if r <> 0 then 
     if q > d then k:=k+1; d:= ithprime(k+1); 
     else t:=t+1; p[t]:=n;
         for j from 1 to t do print(p[j]);
         od;  RETURN();      
     fi;
   else t:=t+1;p[t]:=d;n:=q;
fi;
od;
for j from 1 to t do print(p[j]);
         od;  RETURN();      

end;



