Cuban Prime Calculator
Index
- A Cuban prime is a prime that can be written as the difference of two consecutive cubes divided by the difference of their bases, which simplifies to 3y^2 + 3y + 1.
- For y = 1 the value is 3 x 1^2 + 3 x 1 + 1 = 7 - also the centered hexagonal number for this y.
- Testing 7 for primality: it is prime, with no divisor other than 1 and itself.
- So 7 is a Cuban prime; the next one after it is 19.
The Cuban Prime Calculator checks numbers of the form 3y^2 + 3y + 1 and tells you whether the result is a Cuban prime. A Cuban prime has the form 3y^2 + 3y + 1, which is also the centered hexagonal number for y and equals ((y + 1)^3 - y^3) / ((y + 1) - y). Enter a value of y and the calculator gives you the corresponding number and its status. For example, y = 1 gives 7 and y = 3 gives 37, both Cuban primes. Not every value of y produces a prime: y = 7 gives 169 = 13^2, which is composite, so 169 is not a Cuban prime. The calculator makes these outcomes easy to see without hand arithmetic.
The method behind the calculator is the accepted standard for this kind of calculation because it follows the defining form of a Cuban prime directly. The values 3y^2 + 3y + 1 are exactly the centered hexagonal numbers, so a Cuban prime is a centered hexagonal number that is prime. Testing that form and then checking primality is the established way to identify Cuban primes, and it matches the known sequence, in which the next Cuban prime after 37 is 61 and the next after 169 is 271. This page shows the formula, step-by-step workings, worked examples and sources so you can follow each result and verify it yourself.
Worked examples
y = 1, the smallest Cuban prime
(1)
| Cuban prime verdict | Yes |
| Centered hexagonal number | 7 |
| Prime factorization | Prime |
| Next Cuban prime | 19 |
y = 3, giving 37
(3)
| Cuban prime verdict | Yes |
| Centered hexagonal number | 37 |
| Prime factorization | Prime |
| Next Cuban prime | 61 |
y = 7, giving 169 = 13 squared
(7)
| Cuban prime verdict | No |
| Centered hexagonal number | 169 |
| Prime factorization | 13^2 |
| Next Cuban prime | 271 |
What is a Cuban prime?
A Cuban prime is a prime number that can be written in the form 3y^2 + 3y + 1 for some whole number y. That expression is not an arbitrary recipe: it falls directly out of the difference between two consecutive cubes. Take (y + 1)^3 and subtract y^3, then divide by the difference of the bases, (y + 1) - y. Since that denominator is just 1, the whole quantity simplifies to ((y + 1)^3 - y^3) / ((y + 1) - y), which multiplies out to 3y^2 + 3y + 1. So every Cuban prime is tied to a pair of neighboring cubes, and the form is simply the gap between them written in a cleaner way.
The name has nothing to do with the country Cuba. It refers to cubes. The connection to cubes is the whole point of the definition, which is why a Cuban prime calculator starts from the cube difference and then tests the resulting value for primality. The same expression, 3y^2 + 3y + 1, is also the centered hexagonal number for y. That means the values produced by this formula are exactly the centered hexagonal numbers, laid out one after another as y grows. A Cuban prime, then, is nothing more than a centered hexagonal number that happens to be prime.
Small values make the pattern easy to see. Setting y = 1 gives 3(1) + 3(1) + 1 = 7, and 7 is prime, so 7 is a Cuban prime. Setting y = 3 gives 27 + 9 + 1 = 37, also prime, so 37 qualifies as well. Not every y works, though. Setting y = 7 gives 147 + 21 + 1 = 169, and 169 equals 13^2, which is composite. Because 169 fails the primality test, it is not a Cuban prime even though it sits in the same sequence of centered hexagonal numbers.
The sequence of Cuban primes is not simply every value of the formula in order, because composite results like 169 are skipped. After 37, the next Cuban prime is 61. After 169, the next one is 271. Those jumps show why a dedicated Cuban prime calculator is useful: it can run through candidate values of y, compute 3y^2 + 3y + 1 each time, and keep only the results that are prime, rather than asking you to check each centered hexagonal number by hand.
To use the definition, pick a value of y, evaluate 3y^2 + 3y + 1, and test whether the answer is prime. If it is, you have found a Cuban prime; if it is composite, as with 169, you move on. The formula, the cube difference, and the centered hexagonal numbers all describe the same set of values, so any of those routes leads to the same answer.
Worked examples
A worked example is the quickest way to see how a Cuban prime calculator applies the rule. Every Cuban prime has the form 3y^2 + 3y + 1, where y is a whole number. That same expression is the centered hexagonal number for y, and it also equals ((y + 1)^3 - y^3) / ((y + 1) - y). So the test is simple: plug in a value of y, compute 3y^2 + 3y + 1, and check whether the result is prime.
Start with y = 1. The expression gives 3(1)^2 + 3(1) + 1 = 3 + 3 + 1 = 7. Since 7 has no divisors other than 1 and itself, it is prime, so 7 is a Cuban prime. Next take y = 3: 3(3)^2 + 3(3) + 1 = 27 + 9 + 1 = 37. Again the result is prime, so 37 is a Cuban prime as well. These two cases show the pattern working for small values of y.
Now take y = 7: 3(7)^2 + 3(7) + 1 = 147 + 21 + 1 = 169. The number 169 is not prime, because it factors as 13^2 — that is, 13 times 13. Since 169 is composite, it is not a Cuban prime. This example is useful because 169 looks like a plausible candidate, yet the factoring step rules it out. A Cuban prime calculator performs exactly this check: it evaluates the formula and then tests the result for primality.
The examples also show that the formula does not produce a prime at every value of y. After 37, the next Cuban prime is 61, and after 169 the next is 271. Because the values of 3y^2 + 3y + 1 are exactly the centered hexagonal numbers, a Cuban prime is simply a centered hexagonal number that happens to be prime. That equivalence is what makes the calculation straightforward: generate the centered hexagonal number for a given y, then decide whether it is prime or composite.
| y | 3y^2 + 3y + 1 | Result | Cuban prime? |
|---|---|---|---|
| 1 | 7 | Prime | Yes |
| 3 | 37 | Prime | Yes |
| 7 | 169 = 13^2 | Composite | No |
Centered hexagonal numbers
The expression 3y^2 + 3y + 1 does two jobs at once. It is the formula for a Cuban prime, and it is also the formula for a centered hexagonal number. That is not a coincidence or a quirk of notation: the values 3y^2 + 3y + 1 are exactly the centered hexagonal numbers, so a Cuban prime is simply a centered hexagonal number that happens to be prime. A Cuban prime calculator works on this shared identity, which is why the two ideas are usually explained together.
To see why the same formula counts dots in a hexagonal arrangement, start with one dot in the middle and build outward in rings. The first ring around the center adds six dots, giving seven. The next ring adds twelve, and each new ring adds six more than the ring before it. Adding those rings produces the sequence of centered hexagonal numbers, and the total after y rings is 3y^2 + 3y + 1. The same expression can be written as ((y + 1)^3 - y^3) / ((y + 1) - y), which is the difference of two consecutive cubes divided by the difference of their bases. Both forms describe the same count of dots, one by adding rings and one by subtracting cubes.
Small values show how the dots and the primes line up. With y = 1 the formula gives 7, and with y = 3 it gives 37; both are Cuban primes, and both are centered hexagonal numbers. With y = 7 the formula gives 169, which equals 13^2. Because 169 is composite, it is not a Cuban prime, even though it is still a centered hexagonal number. This is the key distinction: the hexagonal arrangement exists for every y, but only the prime values of the formula qualify as Cuban primes.
The sequence keeps producing primes after these points. After 37 the next Cuban prime is 61, and after 169 the next is 271. Notice that 169 sits between them as a composite centered hexagonal number, a reminder that primality is the filter and the hexagonal count is the underlying shape. When you use a Cuban prime calculator, you are testing centered hexagonal numbers for primality: the formula generates the candidates, and only the prime ones are Cuban primes.
Keeping the two descriptions separate helps avoid confusion. The centered hexagonal number tells you how many dots are in the figure for a given y; the Cuban prime tells you that this particular count is prime. The formula 3y^2 + 3y + 1 is the bridge between them, and every Cuban prime is a centered hexagonal number, though not every centered hexagonal number is a Cuban prime.
How rare are Cuban primes?
Rarity for Cuban primes is best seen by looking at the y values that actually produce a prime. The formula 3y^2 + 3y + 1 does not give a prime every time you plug in a whole number, and the failures are part of what makes the sequence sparse. Take the small cases: y = 1 gives 7 and y = 3 gives 37, both Cuban primes. But y = 7 gives 169, which factors as 13^2. Because 169 is composite, it is not a Cuban prime, even though it is a centered hexagonal number. So the same expression that hands you a prime at one y can hand you a perfect square at the next.
The gaps between successes show the pattern clearly. After 37 the next Cuban prime is 61, and after 169 the next is 271. Notice that 169 sits between 61 and 271 as a composite centered hexagonal number, a reminder that the sequence skips values as often as it includes them. A Cuban prime calculator works by testing each 3y^2 + 3y + 1 in turn and discarding the composites, which is why the output list looks punctuated rather than continuous.
There is a second way to describe the same set, and it sharpens the rarity picture. The values 3y^2 + 3y + 1 are exactly the centered hexagonal numbers, so a Cuban prime is a centered hexagonal number that is prime. That means the Cuban primes inherit whatever is known about primes inside a single polynomial family, and they are a thin slice of the centered hexagonal numbers rather than a separate construction.
The deepest rarity question is whether the list ever ends. It is unknown whether infinitely many Cuban primes exist. No proof establishes an infinite supply, and no proof rules it out; the question stays open. For a general audience, the honest summary is that the sequence begins 7, 37, 61, 271 and continues as far as computation can reach, but whether it continues forever is unsettled. A Cuban prime calculator can enumerate the terms it can verify, yet it cannot settle the infinitude question, because that requires a proof rather than more testing.
FAQs
What is a Cuban prime?
A Cuban prime is a prime number of the form 3y^2 + 3y + 1. That expression is the difference of two consecutive cubes divided by the difference of their bases. So the Cuban primes come from a cube-based formula, and a candidate only counts as a Cuban prime when the resulting value is actually prime.
Is 7 a Cuban prime?
Yes, 7 is a Cuban prime. It is the case y = 1. Plugging 1 into 3y^2 + 3y + 1 gives 3 + 3 + 1, which equals 7, and 7 is prime. That makes 7 the first and smallest Cuban prime, since y = 1 is the starting value for the formula.
Is 169 a Cuban prime?
No. 169 = 13 x 13, so it is composite even though it has the right form (y = 7). The formula at y = 7 produces 169, but a Cuban prime must be prime, and 169 fails that test because it factors as 13 times 13. Having the right form alone is not enough.
Why are they called Cuban primes?
The name comes from cubes, not from Cuba. The formula comes from consecutive cubes: the difference of two consecutive cubes divided by the difference of their bases simplifies to 3y^2 + 3y + 1. So the "Cuban" label refers to the cube-based origin of the expression, not to the country.
What is the Cuban prime after 37?
The Cuban prime after 37 is 61. Moving up through the values of y in the formula 3y^2 + 3y + 1, the next result that is prime comes out to 61, so 61 follows 37 in the sequence of Cuban primes. The calculator lists values in order, letting you check each one.
What is the Cuban prime after 169?
The Cuban prime after 169 is 271. Although 169 itself is composite (169 = 13 x 13) despite having the right form, the next prime produced by the formula 3y^2 + 3y + 1 is 271, so 271 is the Cuban prime that follows 169 in the sequence.