Initializing live version
Download to Desktop

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.

The Ramanujan prime is the smallest positive integer , such that if , then the interval \:2000contains at least primes. This Demonstration plots the tally of primes in the interval against the upper bound of the interval. The Ramanujan primes are labeled on the axis. Notice the tally of primes increases only when the upper bound moves from a composite integer to a prime integer.


The gaps between the Ramanujan primes can include regular primes (green) that fail to be the next . This happens whenever a larger has fewer than primes in its interval . For example, the primes 3, 5 and 7 all fail to be the prime because the intervening intervals with upper bounds at each contain only one prime.


Contributed by: John Kiehl (May 8)
Open content licensed under CC BY-NC-SA


300 BCE Euclid proved in his work Elements (Book IX, Proposition 20) that there is an infinite number of primes; that is, there is no greatest prime. In 1845, Joseph Bertrand made the observation that in any interval there is always at least one prime. In 1919, Ramanujan refined Bertrand's observation by proving there is a steady (but not monotonic) increase in the tally of primes in the intervals as increases. Ramanujan said even more: while the tally of primes jitters around a bit—as seen by the rough contour of this plot—you can always identify that point in the integers where going forward the tally of primes is never less than some value. That point is always a prime, and collectively these points are known as the Ramanujan primes.

The On-line Encyclopedia of Integer Sequences (OEIS) lists the Ramanujan primes at [1]. The sequence starts 2, 11, 17, 29, 41, 47, 59, 67, 71, 97, 101, 107, 127, 149, 151, 167, 179, 181, ….

About 46% of primes less than 19,000 are Ramanujan primes.

About 15% of primes less than 19,000 are the lesser of twin primes.

About 78% of the lesser of twin primes less than 19,000 are Ramanujan primes.

About 26% of the Ramanujan primes less than 19,000 are the lesser of twin primes.

Snapshots 1 and 2: Highlight the first two consecutive Ramanujan primes, and , which are also consecutive regular primes, and . Integer sequence A189993 in the OEIS lists the longest runs of consecutive regular primes that are Ramanujan primes up to for .

Snapshot 3: primes 73, 79, 83, 89 all fail to be , which is a privilege reserved for


[1] J. Sondow. The On-Line Encyclopedia of Integer Sequences. (Apr 19 2023)

[2] J. Sondow, J. W. Nicholson and T. D. Noe, "Ramanujan Primes: Bounds, Runs, Twins, and Gaps," Journal of Integer Sequences, 14, 2011 Article 11.6.2.


Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.