How to create a merits.txt

Creating a merits.txt for reference

Dec 9, 2019 • Graham Higgins • projectdoc

Tom Nicely used to publish a list of merits for checking:

“Furthermore, I have also made available for download the zipfile, which contains a text file specifying the measure G and the merit M=G/ln(p_1) for all known first occurrence and first known occurrence prime gaps. This much smaller file (less than 1 MB) should be of additional assistance in determining whether or not some newly discovered gap constitutes a new first known occurrence.”

Maintaining the list of known first occurrence prime gaps as a file of SQL statements allows users to create their own version, specific to the range of gaps and merits pertinent to the range being searched.

The first step is to download the latest version is available from the github repository at:

The next step is read the list into the SQLite command-line client

$ sqlite3 allgaps.db
SQLite version 3.22.0 2018-01-22 18:45:57
Enter ".help" for usage hints.
sqlite> .read allgaps.sql

The following recipe can be copied and pasted into the sqlite3 command-line client and will create a list of gaps and merits for gaps in the range 10000 and 20000

.mode list
.separator ','
.output merits.txt
SELECT gapsize, merit FROM gaps WHERE gapsize BETWEEN 10000 and 20000 ORDER BY gapsize;

producing a merits.txt file of which the first 10 lines are:


This is how it works on Windows 10:

Screenshot of Windows 10 session

Notepad users will need to adjust the recipe to include an incantation to create a Windows-specific line ending: || char(13)

.mode list
.separator ','
.output merits.txt
SELECT gapsize, merit || char(13) FROM gaps WHERE gapsize BETWEEN 10000 and 20000 ORDER BY gapsize;