primes

package
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Primes is a list of the first n prime numbers
	Primes []int32
	// End is the index of the final value in the Primes slice
	End int
)

Functions

func Index added in v0.18.0

func Index(N int) int

Index returns the index in Primes of n, or negative of the next highest index if not found

func Iter added in v0.20.0

func Iter(start, end int) func(func(int, int) bool)

Iter returns an iterator over Primes

func Load

func Load(name string) []int32

Load returns the contents of the gob file as an int slice

func MakePrimes added in v0.16.0

func MakePrimes(maxPrime uint) []int32

MakePrimes returns all primes <= maxPrime

func Pi

func Pi(n int) int

Pi is the prime counting function, returning the number of primes <= n https://en.wikipedia.org/wiki/Prime-counting_function

func Prime

func Prime(n int) bool

Prime returns true if n is prime

func Save

func Save(primes []int32)

Save writes an int slice to the gob file

func SlowPrime

func SlowPrime(n int) bool

SlowPrime returns whether a number is prime or not, using a brute force search

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL