Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

sieve state

Back to all declarations

MaxN

untyped bigint

MaxN bounds the sieve so gas stays predictable.

Value

(10000 <untyped> bigint)

PrimesUpTo

func(n int) []int

PrimesUpTo returns every prime p with 2 \<= p \<= n, in ascending order, using the Sieve of Eratosthenes. n is clamped to \[0, MaxN]. Pure.

Open
OID
0cd977…39d0:3
PrimesUpTo details

Inspect func

NthPrime

func(k int) int

NthPrime returns the k-th prime (1-indexed), or 0 if it lies beyond MaxN. Pure helper handy for callers and tests.

Open
OID
0cd977…39d0:5
NthPrime details

Inspect func

IsPrime

func(x int) bool

IsPrime reports whether x is prime (trial division). Pure.

Open
OID
0cd977…39d0:6
IsPrime details

Inspect func

Render

func(path string) string

Render renders the sieve for gnoweb. Render("") / Render("/") -> first 100 primes + total count up to MaxN Render("/<n>") -> every prime <= n, laid out as a grid

Open
OID
0cd977…39d0:7
Render details

Inspect func

parseN

func(path string) (int, bool)

parseN extracts n from a Render path like "/1000". Returns hasN=false for the empty/root path.

Open
OID
0cd977…39d0:8
parseN details

Inspect func

grid

func(primes []int, cols int) string

grid formats primes into a Markdown table with \`cols\` columns per row.

Open
OID
0cd977…39d0:9
grid details

Inspect func
MaxN : untyped bigint =(10000 <untyped> bigint)
PrimesUpTo : func(n int) []int Inspect
NthPrime : func(k int) int Inspect
IsPrime : func(x int) bool Inspect
Render : func(path string) string Inspect
parseN : func(path string) (int, bool) Inspect
grid : func(primes []int, cols int) string Inspect