home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / asm / LMPRIME1.ZIP / LMPRIME1.DOC < prev    next >
Encoding:
Text File  |  1991-11-26  |  3.3 KB  |  71 lines

  1. This program is a further outgrowth of the Spring, 1991 contest by Howard
  2. Mencher on the Programmer's Corner (Gary Smith's BBS) in Washington, D.C.
  3. (Columbia, MD) and is based heavily on Bill Parke's response contained in
  4. PRIMES14.  For completeness, this file includes PRIMES14.ZIP.
  5.  
  6. PRIMES14 allowed prime numbers to be generated for any range of numbers
  7. between 1 and 1,048,575, and was written in assembly language for the 8088
  8. cpu. LMPRIME1 goes a step further and extends the range to 4,294,967,295 but
  9. takes advantage of, and requires, an 80386 processor.  The size of the
  10. program is larger than Bill's PRIMES14, but is still small enough
  11. to be contained within 1 cluster (2048 bytes) on most hard disks.
  12.  
  13. The number of primes less than a given number, x, may be estimated by the
  14. following formula attributed to the 19th century German mathematician,
  15. Georg Riemann:
  16.  
  17.                                                          ⌠x
  18.      P(x) = [Li (x)] - .5 x Li (√x),    where  Li(x) =   │    dt / ln t
  19.                                                          ⌡2
  20.  
  21. The accuracy of this formula may be judged by the following table:
  22.  
  23.                   Actual Number
  24.          x       of Primes less       Li (x)            P(x)
  25.                     than x
  26.  
  27.           100            25               29              27
  28.         1,000           168              177             170
  29.        10,000         1,229            1,245           1,231
  30.       100,000         9,592            9,629           9,594
  31.     1,000,000        78,498           78,627          78,538
  32.    10,000,000       664,579          664,917         664,686
  33.   100,000,000     5,761,455        5,762,208       5,761,586
  34. 1,000,000,000    50,847,568       50,849,234      50,847,517
  35.  
  36.  
  37. The syntax for running LMPRIME1 is
  38.  
  39.                 LMPRIME1 n1 n2 [/] [/?]
  40.  
  41. where n1 and n2 are decimal digits (no comma delimiters) with
  42. 0 < n1 < n2 < 4,294,967,295
  43.  
  44. The program will give a listing of all primes between n1 and n2 and
  45. a count of the number of such primes.
  46.  
  47. The optional / will suppress listing individual primes, supplying only
  48. the count of the number of primes.
  49.  
  50. The program is compatible with DOS 5, so that supplying only the argument
  51. /? will produce a small help message.  For those using the DOS help
  52. facility and DOSHELP.HLP, the DOS command HELP LMPRIME1 will also produce
  53. the help message (provided LMPRIME1 has been added to DOSHELP.HLP).
  54.  
  55. The number of primes contained on each line of output is dependent on the
  56. size of the largest prime.  For example, with an 80-column screen,
  57. LMPRIME1 1 90 will produce 24 primes on one line, while
  58. LMPRIME1 4000000000 4000000200 will require two lines to produce 8 primes.
  59. The program can also be used with either a 40-column screen or a 132-column
  60. screen.
  61.  
  62. If your system contains an 80x87 math coprocessor, LMPRIME1.COM contained
  63. in this file does not make use of the math chip.  However, the source code
  64. contained in LMPRIME1.ASM can easily be modified to take advantage of the
  65. 80x87 by changing the definition of IS8087 from 0 to 1.  There is no major
  66. speedup in calculation time; however the resulting .COM file will be smaller.
  67.  
  68.  
  69.                                                 Les Moskowitz
  70.                                                 11/26/91
  71.