primes

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxPrime is the highest value up to which we will search for primes
	MaxPrime = 100*1000*1000 + 1000
)

Variables

View Source
var (

	// PackedPrimes is a list of the first n prime numbers
	PackedPrimes []int
	// PackedPrimesEnd is the index of the final value in the PackedPrimes slice
	PackedPrimesEnd int
)

Functions

func GeneratePrimesGob added in v0.0.10

func GeneratePrimesGob()

GeneratePrimesGob finds, packs, and saves primes to a GOB file

func Load

func Load(fName string)

Load reads the contents of a file into PackedPrimes

func PackedIndex

func PackedIndex(n int) int

PackedIndex returns the index in PackedPrimes 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()

Save writes PackedPrimes to a 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