home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l224 / 2.img / TFEXMPL2.ZIP / PRIME1.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-29  |  275 b   |  23 lines

  1. /* Copyright (c) 1990, Borland International */
  2. #include <stdio.h>
  3.  
  4. prime(int n)
  5. {
  6.     int i;
  7.  
  8.     for (i=2; i<n; i++)
  9.         if (n % i == 0)
  10.             return 0;
  11.     return 1;
  12. }
  13.  
  14. main()
  15. {
  16.     int i, n;
  17.  
  18.     n = 1000;
  19.     for (i=2; i<=n; i++)
  20.         if (prime(i))
  21.             printf("%d\n", i);
  22. }
  23.