Documentation

Complexity.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.

Instances For
    @[reducible, inline]

    Current trial-division candidate.

    Instances For
      @[reducible, inline]

      Current candidate's primality bit.

      Instances For
        @[reducible, inline]

        Largest candidate.

        Instances For
          @[reducible, inline]

          Output bitmap base.

          Instances For
            @[reducible, inline]

            First candidate not yet written.

            Instances For
              @[reducible, inline]

              Address scratch.

              Instances For
                @[reducible, inline]

                Number of primes written.

                Instances For
                  @[reducible, inline]

                  One past the largest candidate.

                  Instances For
                    @[reducible, inline]

                    Constant one.

                    Instances For
                      @[reducible, inline]

                      Constant zero.

                      Instances For
                        @[reducible, inline]

                        Constant two.

                        Instances For

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

                          Instances For

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

                            Instances For

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

                              Instances For

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

                                Instances For

                                  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.