Lucky Number Calculator

Find the lucky number at an index from a sieve that repeatedly removes every kth remaining entry.

Math and PercentUpdated 2026-11-182 min read
Lucky Number Calculator
A whole number from 1 to 1,000.
Lucky number
...
Previous lucky number...
Gap to previous...

What it does

Lucky numbers are produced by a sieve similar to the sieve of Eratosthenes, but the rule changes as the process runs. Start with the odd positive integers. The second surviving number is 3, so remove every third remaining number. The next survivor is 7, so remove every seventh remaining number, and so on.

The numbers that survive forever are called lucky. The sequence begins 1, 3, 7, 9, 13, 15, 21 and 25. The name was coined in the twentieth century, and the construction is attributed to work by Stanislaw Ulam and colleagues.

Lucky numbers share surprising statistical properties with the primes. For instance, the number of lucky numbers up to a large limit behaves similarly to the prime counting function, even though the two sequences are defined in completely different ways.

This page runs the sieve up to a bounded limit and returns the lucky number at your chosen index. It also shows the previous lucky number and the gap between them.

The index limit is one thousand, which is well inside the sieve bound so the answer is reliable. Increasing the bound further would slow the page without changing these early terms.

How to use

  1. Enter an index n from 1 to 1,000.
  2. Read the lucky number at that index in the main result box.
  3. Check the previous lucky number beside it.
  4. Use the gap to see how far apart the survivors are.
  5. The default index 5 reproduces the worked example.
  6. Try index 6 to confirm the value 15.

Formula

Start with odd integers; at step k remove every list[k]th remaining entry, where list[k] is the current surviving value at that position
list
The current ordered list of surviving candidates.
list[k]
The survivor whose value gives the removal step.
k
The index of the current sieve pass.

The sieve starts with 1, 3, 5, 7 and so on. On the first pass every third entry is removed, on the second every seventh, using the next surviving value each time. The process stops once the next step exceeds the length of the list.

Worked example

Example: index 5

The page opens with index 5.

  1. Start with odd numbers 1, 3, 5, 7, 9, 11, 13, 15 and so on.
  2. The second survivor is 3, so remove every third entry.
  3. The list becomes 1, 3, 7, 9, 13, 15, 21 and so on.
  4. The next survivor is 7, so remove every seventh remaining entry.
  5. The early survivors are 1, 3, 7, 9, 13 and 15.
  6. The tool reports lucky 13, previous 9, and gap 4.

Reference table

Lucky numbers at small indices
nLucky(n)PreviousGap
11n/an/a
2312
3734
4972
51394
615132
1033312

Limits

  • Indices above 1,000 are rejected to keep the sieve quick.
  • The sieve uses a fixed upper bound, which is more than enough for these indices.
  • The tool returns one term, not the whole surviving list.
  • Lucky numbers are not the same as prime numbers, though they behave similarly.

Common mistakes

  • Starting the sieve with all integers instead of only odd ones.
  • Using a fixed step of two for every pass.
  • Using the index rather than the surviving value as the removal step.
  • Assuming lucky numbers are a subset of the primes.
  • Forgetting that 1 is counted as the first lucky number.

Try it yourself

Quick checks. Answers sit tucked under each question.

What is the fifth lucky number?

13, with 9 before it and a gap of 4.

What is the sixth lucky number?

15.

What is the first lucky number?

1, the first survivor of the sieve.

Questions

How is the sieve different from Eratosthenes?

The removal step changes with each surviving value rather than being the next prime.

Why are they called lucky?

The name reflects the survival process, popularised in work by Ulam and colleagues.

Do they behave like primes?

Their counting function has similar asymptotic behaviour, though the sequences differ.

Is 1 a lucky number?

Yes, it is the first survivor.

Are results exact?

Yes. The sieve uses integer lists only.

What index range is accepted?

One through 1,000.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.