home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / TESTS / LF / FACTORIZ.LF < prev    next >
Text File  |  1996-06-04  |  338b  |  12 lines

  1. prime := I:int | length(factors(I))=1.
  2.  
  3. factors(N:int) -> cond(N<0,
  4.                        {},
  5.                        factorize(N,2)).
  6.  
  7. factorize(N,P) -> cond(P*P>N,
  8.                        [N],
  9.                        cond(R:(N/P)=:=floor(R),
  10.                             [P|factorize(R,P)],
  11.                             factorize(N,P+1))).
  12.