home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / hcshdemo.zip / csh-os2.zip / SAMPLES / FACTOR.CSH < prev    next >
Text File  |  1993-09-28  |  304b  |  17 lines

  1. #    Calculate the prime factors of an integer.
  2. #    Copyright (c) 1989 by Hamilton Laboratories.  All rights reserved.
  3.         
  4. proc factor(n)
  5.     if (n > 3) then
  6.         for i = 2 to floor(sqrt(n)) do
  7.             if (n % i == 0) then
  8.                 echo $i
  9.                 return factor(n//i)
  10.             end
  11.         end
  12.     end
  13.     return n
  14. end
  15.  
  16. factor $argv
  17.