The Project Gutenberg eBook, Primes to One Trillion, Edited by Don Kostuch
This eBook is for the use of anyone anywhere in the United States and most other parts of the world at no cost and with almost no restrictions whatsoever. You may copy it, give it away or re-use it under the terms of the Project Gutenberg License included with this eBook or online atwww.gutenberg.org. If you are not located in the United States, you'll have to check the laws of the country where you are located before using this ebook.
Title: Primes to One Trillion
Editor: Don Kostuch
Release Date: November 3, 2018 [eBook #58225]
Language: English
Character set encoding: ASCII
***START OF THE PROJECT GUTENBERG EBOOK PRIMES TO ONE TRILLION***
The Gutenberg text "The First 100,000 Prime Numbers", EBook #65, lists the primes up to 1,318,699. This somewhat more ambitious version lists the primes up to one trillion (1,000,000,000,000 or 1E12).
I became interested in prime numbers after hearing aboutGoldbach's Conjecture,
"Every even integer greater than 2 can be expressed as the sum of two primes".
Verifying this requires a source of primes. Short lists (or programs to generate them) are widely available. Really long lists are scarce, except forprimos.mat.br.
To make these lists more accessible, I have reformatted them to a size easily manageable by ordinary text editors and viewers--about 55MB. The file names correspond to the range of primes the file contains:
The leading zero digits cause the file names to collate in order of their content. Longer lists can be composed with the DOS copy command. Move the required prime txt files to a temporary directory and use:
copy *.txt longList.txt
This is a collection of 10,000 files, occupying about 486GB of disk space in their unzipped native txt format. Since adjacent primes have about 90% identical leading digits, the compressed (zip) versions total 61GB. Each zip file contains 100 txt files.
Do not use Windows Explorer to copy or move large numbers of files at a time. Use DOScopyorxcopyfor large copies. I findBeyond Compare(Scooter Software) handy for keeping track of large numbers of files.
The following zip file names denotes the start of a range of primes in billions (1,000,000,000), and covers a range of 10,000,000,000. Each zip file contains 100 txt files, each covering the primes in a range of 100,000,000.
0000.zip000G to 010G (0 to 1E10)0010.zip010G to 020G0020.zip020G to 030G0030.zip030G to 040G0040.zip040G to 050G0050.zip050G to 060G0060.zip060G to 070G0070.zip070G to 080G0080.zip080G to 090G0090.zip090G to 100G0100.zip100G to 110G0110.zip110G to 120G0120.zip120G to 130G0130.zip130G to 140G0140.zip140G to 150G0150.zip150G to 160G0160.zip160G to 170G0170.zip170G to 180G0180.zip180G to 190G0190.zip190G to 100G0200.zip200G to 210G0210.zip210G to 220G0220.zip220G to 230G0230.zip230G to 240G0240.zip240G to 250G0250.zip250G to 260G0260.zip260G to 270G0270.zip270G to 280G0280.zip280G to 290G0290.zip290G to 200G0300.zip300G to 310G0310.zip310G to 320G0320.zip320G to 330G0330.zip330G to 340G0340.zip340G to 350G0350.zip350G to 360G0360.zip360G to 370G0370.zip370G to 380G0380.zip380G to 390G0390.zip390G to 300G0400.zip400G to 410G0410.zip410G to 420G0420.zip420G to 430G0430.zip430G to 440G0440.zip440G to 450G0450.zip450G to 460G0460.zip460G to 470G0470.zip470G to 480G0480.zip480G to 490G0490.zip490G to 400G0500.zip500G to 510G0510.zip510G to 520G0520.zip520G to 530G0530.zip530G to 540G0540.zip540G to 550G0550.zip550G to 560G0560.zip560G to 570G0570.zip570G to 580G0580.zip580G to 590G0590.zip590G to 500G0600.zip600G to 610G0610.zip610G to 620G0620.zip620G to 630G0630.zip630G to 640G0640.zip640G to 650G0650.zip650G to 660G0660.zip660G to 670G0670.zip670G to 680G0680.zip680G to 690G0690.zip690G to 600G0700.zip700G to 710G0710.zip710G to 720G0720.zip720G to 730G0730.zip730G to 740G0740.zip740G to 750G0750.zip750G to 760G0760.zip760G to 770G0770.zip770G to 780G0780.zip780G to 790G0790.zip790G to 700G0800.zip800G to 810G0810.zip810G to 820G0820.zip820G to 830G0830.zip830G to 840G0840.zip840G to 850G0850.zip850G to 860G0860.zip860G to 870G0870.zip870G to 880G0880.zip880G to 890G0890.zip890G to 800G0900.zip900G to 910G0910.zip910G to 920G0920.zip920G to 930G0930.zip930G to 940G0940.zip940G to 950G0950.zip950G to 960G0960.zip960G to 970G0970.zip970G to 980G0980.zip980G to 990G0990.zip990G to 1000G
While working with primes, I developed theprimecformat, a file or array representation for primes that is roughly the same size of the compressed (zipped) txt representation, and supports fast access, both sequential and direct. The exact location of the primality specification of any number in the file (or memory array) is computed with a few instructions and no search.
If you wish to examine and experiment with the C++ programs used to reformat these prime lists and test the Goldbach Conjecture, download the "programs.zip" package. It containsGenerating and Analyzing Prime Numbers, a description of the content and use of these files, including theprimecfile format.
Theprimecformat exploits the fact that all primes greater than 5 end in the decimal digits 1, 3, 7, or 9. Thus, the primality of 20 successive numbers can be specified in one 8 bit byte. The file begins with the complete binary representation of:
The beginning of the sequenceThe end of the sequenceA check sum of all data bytes(All three are 8 bytes for this implementation).
The first and last values are a multiple of twenty, thus are never primes. There is no overlap of primes between successive files that use the same number for the upper boundary of the first file, and the lower boundary of the second file.
The primality of any number in the range of the file is determined as follows:
If the number ends in 0, 2, 4, 5, 6, or 8, it is not prime.Otherwise, the location of the specifying byte is at offset:( value - start ) / 20Within that byte, the primality of the value is specified by the bit as shown in the following table.
The only tedious programming tasks were:
Special case code for values less than 20, which include 2 and 5, and exclude 1 and 9. All larger values follow the same simple pattern.The increment and decrement operators for the corresponding iterators must search forward (or backward) for the next true bit, specifying the next prime number.
This table shows the layout and content for a file containing 20 to 60. The first 24 bytes (start value, end value, check sum) are not shown.
As primes become larger, the density of primes becomes smaller as1/ln(n). Thus the density of true bits also falls off. The number of digits (binary or decimal) to represent the primes grows asln(n). Thus, a sequence of primes represented asprimecis always competitive in size with the corresponding sequence in ASCI text or binary, besides providing fast direct access by value:
bool isPrime(value).
The results for the sequence of the largest 64 bit primes (18446744073707000000 to 18446744073709551558) is:
Among the programs in the "program.zip" package are:
Among the more than 15 classes and utilities are:
I hope you find them useful.
If you have any questions, observations or bug reports concerning the C++ programming or the content of the prime files, send an email (after changing "at" to "@".
primes1e12 at earthlink.net
I embarked on this project as a programming challenge. I am not a mathematician. I have no deep insight into prime number theory. Please confine messages to programming issues. Here are some references:
Prime NumbersWikipedia: List of Prime Numbers (with numerous references)The Math ForumThe Prime Pages
The program files are also posted onhttp://home.earthlink.net/~primes1E12.Corrections and additions will be posted there as they occur.
Don KostuchOctober, 2018.
***END OF THE PROJECT GUTENBERG EBOOK PRIMES TO ONE TRILLION***
******* This file should be named 58225-h.htm or 58225-h.zip *******
This and all associated files of various formats will be found in:http://www.gutenberg.org/5/8/2/2/58225
Updated editions will replace the previous one--the old editions will be renamed.
Creating the works from print editions not protected by U.S. copyright law means that no one owns a United States copyright in these works, so the Foundation (and you!) can copy and distribute it in the United States without permission and without paying copyright royalties. Special rules, set forth in the General Terms of Use part of this license, apply to copying and distributing Project Gutenberg-tm electronic works to protect the PROJECT GUTENBERG-tm concept and trademark. Project Gutenberg is a registered trademark, and may not be used if you charge for the eBooks, unless you receive specific permission. If you do not charge anything for copies of this eBook, complying with the rules is very easy. You may use this eBook for nearly any purpose such as creation of derivative works, reports, performances and research. They may be modified and printed and given away--you may do practically ANYTHING in the United States with eBooks not protected by U.S. copyright law. Redistribution is subject to the trademark license, especially commercial redistribution.
To protect the Project Gutenberg-tm mission of promoting the free distribution of electronic works, by using or distributing this work (or any other work associated in any way with the phrase "Project Gutenberg"), you agree to comply with all the terms of the Full Project Gutenberg-tm License available with this file or online at www.gutenberg.org/license.
1.A. By reading or using any part of this Project Gutenberg-tm electronic work, you indicate that you have read, understand, agree to and accept all the terms of this license and intellectual property (trademark/copyright) agreement. If you do not agree to abide by all the terms of this agreement, you must cease using and return or destroy all copies of Project Gutenberg-tm electronic works in your possession. If you paid a fee for obtaining a copy of or access to a Project Gutenberg-tm electronic work and you do not agree to be bound by the terms of this agreement, you may obtain a refund from the person or entity to whom you paid the fee as set forth in paragraph 1.E.8.
1.B. "Project Gutenberg" is a registered trademark. It may only be used on or associated in any way with an electronic work by people who agree to be bound by the terms of this agreement. There are a few things that you can do with most Project Gutenberg-tm electronic works even without complying with the full terms of this agreement. See paragraph 1.C below. There are a lot of things you can do with Project Gutenberg-tm electronic works if you follow the terms of this agreement and help preserve free future access to Project Gutenberg-tm electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation ("the Foundation" or PGLAF), owns a compilation copyright in the collection of Project Gutenberg-tm electronic works. Nearly all the individual works in the collection are in the public domain in the United States. If an individual work is unprotected by copyright law in the United States and you are located in the United States, we do not claim a right to prevent you from copying, distributing, performing, displaying or creating derivative works based on the work as long as all references to Project Gutenberg are removed. Of course, we hope that you will support the Project Gutenberg-tm mission of promoting free access to electronic works by freely sharing Project Gutenberg-tm works in compliance with the terms of this agreement for keeping the Project Gutenberg-tm name associated with the work. You can easily comply with the terms of this agreement by keeping this work in the same format with its attached full Project Gutenberg-tm License when you share it without charge with others.
1.D. The copyright laws of the place where you are located also govern what you can do with this work. Copyright laws in most countries are in a constant state of change. If you are outside the United States, check the laws of your country in addition to the terms of this agreement before downloading, copying, displaying, performing, distributing or creating derivative works based on this work or any other Project Gutenberg-tm work. The Foundation makes no representations concerning the copyright status of any work in any country outside the United States.
1.E. Unless you have removed all references to Project Gutenberg:
1.E.1. The following sentence, with active links to, or other immediate access to, the full Project Gutenberg-tm License must appear prominently whenever any copy of a Project Gutenberg-tm work (any work on which the phrase "Project Gutenberg" appears, or with which the phrase "Project Gutenberg" is associated) is accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United States and most other parts of the world at no cost and with almost no restrictions whatsoever. You may copy it, give it away or re-use it under the terms of the Project Gutenberg License included with this eBook or online atwww.gutenberg.org. If you are not located in the United States, you'll have to check the laws of the country where you are located before using this ebook.
This eBook is for the use of anyone anywhere in the United States and most other parts of the world at no cost and with almost no restrictions whatsoever. You may copy it, give it away or re-use it under the terms of the Project Gutenberg License included with this eBook or online atwww.gutenberg.org. If you are not located in the United States, you'll have to check the laws of the country where you are located before using this ebook.
1.E.2. If an individual Project Gutenberg-tm electronic work is derived from texts not protected by U.S. copyright law (does not contain a notice indicating that it is posted with permission of the copyright holder), the work can be copied and distributed to anyone in the United States without paying any fees or charges. If you are redistributing or providing access to a work with the phrase "Project Gutenberg" associated with or appearing on the work, you must comply either with the requirements of paragraphs 1.E.1 through 1.E.7 or obtain permission for the use of the work and the Project Gutenberg-tm trademark as set forth in paragraphs 1.E.8 or 1.E.9.
1.E.3. If an individual Project Gutenberg-tm electronic work is posted with the permission of the copyright holder, your use and distribution must comply with both paragraphs 1.E.1 through 1.E.7 and any additional terms imposed by the copyright holder. Additional terms will be linked to the Project Gutenberg-tm License for all works posted with the permission of the copyright holder found at the beginning of this work.
1.E.4. Do not unlink or detach or remove the full Project Gutenberg-tm License terms from this work, or any files containing a part of this work or any other work associated with Project Gutenberg-tm.
1.E.5. Do not copy, display, perform, distribute or redistribute this electronic work, or any part of this electronic work, without prominently displaying the sentence set forth in paragraph 1.E.1 with active links or immediate access to the full terms of the Project Gutenberg-tm License.
1.E.6. You may convert to and distribute this work in any binary, compressed, marked up, nonproprietary or proprietary form, including any word processing or hypertext form. However, if you provide access to or distribute copies of a Project Gutenberg-tm work in a format other than "Plain Vanilla ASCII" or other format used in the official version posted on the official Project Gutenberg-tm web site (www.gutenberg.org), you must, at no additional cost, fee or expense to the user, provide a copy, a means of exporting a copy, or a means of obtaining a copy upon request, of the work in its original "Plain Vanilla ASCII" or other form. Any alternate format must include the full Project Gutenberg-tm License as specified in paragraph 1.E.1.
1.E.7. Do not charge a fee for access to, viewing, displaying, performing, copying or distributing any Project Gutenberg-tm works unless you comply with paragraph 1.E.8 or 1.E.9.
1.E.8. You may charge a reasonable fee for copies of or providing access to or distributing Project Gutenberg-tm electronic works provided that
1.E.9. If you wish to charge a fee or distribute a Project Gutenberg-tm electronic work or group of works on different terms than are set forth in this agreement, you must obtain permission in writing from both the Project Gutenberg Literary Archive Foundation and The Project Gutenberg Trademark LLC, the owner of the Project Gutenberg-tm trademark. Contact the Foundation as set forth in Section 3 below.
1.F.
1.F.1. Project Gutenberg volunteers and employees expend considerable effort to identify, do copyright research on, transcribe and proofread works not protected by U.S. copyright law in creating the Project Gutenberg-tm collection. Despite these efforts, Project Gutenberg-tm electronic works, and the medium on which they may be stored, may contain "Defects," such as, but not limited to, incomplete, inaccurate or corrupt data, transcription errors, a copyright or other intellectual property infringement, a defective or damaged disk or other medium, a computer virus, or computer codes that damage or cannot be read by your equipment.
1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for the "Right of Replacement or Refund" described in paragraph 1.F.3, the Project Gutenberg Literary Archive Foundation, the owner of the Project Gutenberg-tm trademark, and any other party distributing a Project Gutenberg-tm electronic work under this agreement, disclaim all liability to you for damages, costs and expenses, including legal fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.
1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you discover a defect in this electronic work within 90 days of receiving it, you can receive a refund of the money (if any) you paid for it by sending a written explanation to the person you received the work from. If you received the work on a physical medium, you must return the medium with your written explanation. The person or entity that provided you with the defective work may elect to provide a replacement copy in lieu of a refund. If you received the work electronically, the person or entity providing it to you may choose to give you a second opportunity to receive the work electronically in lieu of a refund. If the second copy is also defective, you may demand a refund in writing without further opportunities to fix the problem.
1.F.4. Except for the limited right of replacement or refund set forth in paragraph 1.F.3, this work is provided to you 'AS-IS', WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
1.F.5. Some states do not allow disclaimers of certain implied warranties or the exclusion or limitation of certain types of damages. If any disclaimer or limitation set forth in this agreement violates the law of the state applicable to this agreement, the agreement shall be interpreted to make the maximum disclaimer or limitation permitted by the applicable state law. The invalidity or unenforceability of any provision of this agreement shall not void the remaining provisions.
1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation, the trademark owner, any agent or employee of the Foundation, anyone providing copies of Project Gutenberg-tm electronic works in accordance with this agreement, and any volunteers associated with the production, promotion and distribution of Project Gutenberg-tm electronic works, harmless from all liability, costs and expenses, including legal fees, that arise directly or indirectly from any of the following which you do or cause to occur: (a) distribution of this or any Project Gutenberg-tm work, (b) alteration, modification, or additions or deletions to any Project Gutenberg-tm work, and (c) any Defect you cause.
Project Gutenberg-tm is synonymous with the free distribution of electronic works in formats readable by the widest variety of computers including obsolete, old, middle-aged and new computers. It exists because of the efforts of hundreds of volunteers and donations from people in all walks of life.
Volunteers and financial support to provide volunteers with the assistance they need are critical to reaching Project Gutenberg-tm's goals and ensuring that the Project Gutenberg-tm collection will remain freely available for generations to come. In 2001, the Project Gutenberg Literary Archive Foundation was created to provide a secure and permanent future for Project Gutenberg-tm and future generations. To learn more about the Project Gutenberg Literary Archive Foundation and how your efforts and donations can help, see Sections 3 and 4 and the Foundation information page at www.gutenberg.org.
The Project Gutenberg Literary Archive Foundation is a non profit 501(c)(3) educational corporation organized under the laws of the state of Mississippi and granted tax exempt status by the Internal Revenue Service. The Foundation's EIN or federal tax identification number is 64-6221541. Contributions to the Project Gutenberg Literary Archive Foundation are tax deductible to the full extent permitted by U.S. federal laws and your state's laws.
The Foundation's principal office is in Fairbanks, Alaska, with the mailing address: PO Box 750175, Fairbanks, AK 99775, but its volunteers and employees are scattered throughout numerous locations. Its business office is located at 809 North 1500 West, Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up to date contact information can be found at the Foundation's web site and official page at www.gutenberg.org/contact
For additional contact information:
Dr. Gregory B. NewbyChief Executive and Directorgbnewby@pglaf.org
Project Gutenberg-tm depends upon and cannot survive without wide spread public support and donations to carry out its mission of increasing the number of public domain and licensed works that can be freely distributed in machine readable form accessible by the widest array of equipment including outdated equipment. Many small donations ($1 to $5,000) are particularly important to maintaining tax exempt status with the IRS.
The Foundation is committed to complying with the laws regulating charities and charitable donations in all 50 states of the United States. Compliance requirements are not uniform and it takes a considerable effort, much paperwork and many fees to meet and keep up with these requirements. We do not solicit donations in locations where we have not received written confirmation of compliance. To SEND DONATIONS or determine the status of compliance for any particular state visitwww.gutenberg.org/donate.
While we cannot and do not solicit contributions from states where we have not met the solicitation requirements, we know of no prohibition against accepting unsolicited donations from donors in such states who approach us with offers to donate.
International donations are gratefully accepted, but we cannot make any statements concerning tax treatment of donations received from outside the United States. U.S. laws alone swamp our small staff.
Please check the Project Gutenberg Web pages for current donation methods and addresses. Donations are accepted in a number of other ways including checks, online payments and credit card donations. To donate, please visit: www.gutenberg.org/donate
Professor Michael S. Hart was the originator of the Project Gutenberg-tm concept of a library of electronic works that could be freely shared with anyone. For forty years, he produced and distributed Project Gutenberg-tm eBooks with only a loose network of volunteer support.
Project Gutenberg-tm eBooks are often created from several printed editions, all of which are confirmed as not protected by copyright in the U.S. unless a copyright notice is included. Thus, we do not necessarily keep eBooks in compliance with any particular paper edition.
Most people start at our Web site which has the main PG search facility: www.gutenberg.org
This Web site includes information about Project Gutenberg-tm, including how to make donations to the Project Gutenberg Literary Archive Foundation, how to help produce our new eBooks, and how to subscribe to our email newsletter to hear about new eBooks.