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 package

Overview

Package sieve is an on-chain port of Go's classic concurrent prime sieve (the "prime sieve" example from the Go tour / Go source docs), implemented as a deterministic, allocation-friendly Sieve of Eratosthenes so it runs reproducibly on-chain (no goroutines, channels, or clocks).

Functions

IsPrime

func IsPrime(x int) bool

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

Param

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/sieve.IsPrime()"

Result

NthPrime

func NthPrime(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.

Param

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/sieve.NthPrime()"

Result

PrimesUpTo

func PrimesUpTo(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.

Param

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/sieve.PrimesUpTo()"

Result

Render

func Render(path string) string

Render renders the sieve for gnoweb.

Example
1Render("")      / Render("/") -> first 100 primes + total count up to MaxN
2Render("/<n>")               -> every prime <= n, laid out as a grid

Param

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/sieve.Render()"

Result