Factor.csh



#  Calculate the prime factors of an integer.
#  Copyright (c) 1989 by Hamilton Laboratories.  All rights reserved.
      
proc factor(n)
   if (n > 3) then
      for i = 2 to floor(sqrt(n)) do
         if (n % i == 0) then
            echo $i
            return factor(n//i)
         end
      end
   end
   return n
end

factor $argv



Hamilton C shell | Free Updates | Free Demo Software | Win32 Training
Y2K | Customer Testimonials | On-line Hamilton C shell User Guide
Home | Email | Support | Company Profile | Distributors | Links



Copyright © 1997-2001 by Hamilton Laboratories. All rights reserved.
You are visitor number 468. This page was last modified August 14, 2001.