VM / little experiments On your device

Fun with primes

Keep scrolling. Your device makes more prime numbers as you go.

Session stats
Primes explored
0
Largest discovered
—
Last batch
—

One background worker, no database. Older rows are regenerated when you scroll back. This session pauses at 1 trillion to keep calculations bounded.

About this experiment

A small museum of mathematical curiosity

A question that kept growing.

A personal project by Vincent Mossman, from a high-school twin-prime search to college experiments in C and the browser list you can explore today.

These early experiments predate today’s AI coding assistants.

  1. c. 2012–2013 · High school

    Looking for pairs

    A C++ program checked numbers by trial division, looking for pairs of primes two apart. Date recalled by Vincent.

    The original search ↗
  2. 2016 · College-era experiments

    Sharing the work

    Source updated November 5, 2016. Experiments in C explored prime gaps and sieves. threadPartialSieve split the factor-marking work across four POSIX threads.

    The C experiments ↗
  3. 2026 · Browser showcase

    An open-ended list

    This 2026 presentation brings the experiments together. Primes are generated in your browser as you scroll.

    The browser project ↗

From the archive · source updated November 5, 2016

threadPartialSieve

Four threads split the sieve’s factor-marking passes, crossing out multiples in one shared array. A college-era experiment Vincent is still proud of.

void *threadPartialSieve(void *rank) {

  long unsigned int i, j;

  // run sieve
  for (i = (long unsigned int) rank+1; i < sqrt(globalN); i+=numberOfThreads) {
    for (j = i; j < globalN; j+=(i+1)) {
      if (i > (long unsigned int) rank+1 && (i+1)%2 == 0) {break;}
      if (j > i) {
        isPrimeArray[j] = FALSE;
      } // end if
    } // end for (j)
  } // end for (i)

} // end threadPartialSieve

Complete function, preserved as written. The caller, shared variables, and thread setup are in the full source.

This historical experiment has unsynchronized shared writes and includes 1 in its output. Today’s list uses a separate JavaScript Web Worker.

View the original source ↗

Only divisible by 1 and themselves

Select a number

A prime number. No divisors but 1 and itself.