home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / intercal.zip / pit / primes.doc < prev    next >
Text File  |  1994-04-25  |  987b  |  19 lines

  1. primes.i is a simple program for printing out a list of prime numbers.
  2. It has an outer loop variable .11 and an inner loop variable .13, both
  3. of which start at #3 and advance through odd numbers.  .13 contains the
  4. numbers being tested as possible divisors of .11, which is the number
  5. being tested for primality.  Each time through the inner loop a 16-bit
  6. division with remainder routine (2030) is called to divide .11 by .13.
  7. If .13 is greater than the quotient then .11 is known to be prime and
  8. is printed out.  If the remainder is #0, on the other hand, then .11
  9. is known to be composite and the inner loop is terminated prematurely.
  10.  
  11. The termination test for the outer loop is controlled by statement (22),
  12. which tests to see if the high bit of (.11-#1)/#2 is set.  You can
  13. modify this statement to test some other bit if you want the program
  14. to terminate sooner.  It took over 17 hours on a Sparc 1 for this
  15. program to find all 16-bit primes.
  16.  
  17.                 Louis Howell
  18.                 December 30, 1991
  19.