Documentation

CslibFrontier.Algorithms.WordRAM.PrimeTable

Native prime tables #

This fixed program tests every candidate through the supplied bound, writes its primality bit, and counts the primes. Trial division, table addresses, writes and loops are charged. There is no primality oracle or assumed sieve.

Main definitions #

Main results #

Registers of the trial-division subroutine.

@[reducible, inline]

Current trial-division candidate.

@[reducible, inline]

Current candidate's primality bit.

@[reducible, inline]

Largest candidate.

@[reducible, inline]

Output bitmap base.

@[reducible, inline]

First candidate not yet written.

@[reducible, inline]

Address scratch.

@[reducible, inline]

Number of primes written.

@[reducible, inline]

One past the largest candidate.

@[reducible, inline]

Constant one.

@[reducible, inline]

Constant zero.

@[reducible, inline]

Constant two.

Handle zero and one directly; test all larger candidates by charged native trial division.

Test, write the bit, update the count, and advance the candidate.

A finite native prime-table program with its bound and base supplied in registers.

The first k primality bits, preserving all other memory cells.

Write every primality bit through m, count exactly Nat.primesLE m, and preserve all cells outside the bitmap. Trial division gives the explicit quadratic bound (m+1)(7m+15)+8; the final halt is excluded.