primes

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: MIT Imports: 5 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 []int
	// PrimesEnd is the index of the final value in the Primes slice
	PrimesEnd int
)

Functions

func Load

func Load(fName string) []int

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

func MakePrimes added in v0.16.0

func MakePrimes(maxPrime int) []int

MakePrimes returns all primes <= maxPrime

func PackedIndex

func PackedIndex(n int) int

PackedIndex returns the index in Primes of n, or -1 if not found

func Pi

func Pi(n int) int

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

func Prime

func Prime(number int) bool

Prime returns true if number is prime

func Save

func Save(primes []int)

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