prime

package
v0.0.3-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Factorize

func Factorize(n int64) map[int64]int64

Factorize is a function that computes the exponents of each prime in the prime factorization of n

func Generate

func Generate(limit int) []int

Generate returns a int slice of prime numbers up to the limit

func GenerateChannel

func GenerateChannel(ch chan<- int)

Generate generates the sequence of integers starting at 2 and sends it to the channel `ch`

func MillerRabinTest

func MillerRabinTest(num, rounds int64) (bool, error)

MillerRabinTest Probabilistic test for primality of an integer based of the algorithm devised by Miller and Rabin.

func MillerTest

func MillerTest(d, num int64) (bool, error)

MillerTest This is the intermediate step that repeats within the miller rabin primality test for better probabilitic chances of receiving the correct result.

func NaiveApproach

func NaiveApproach(n int) bool

NaiveApproach checks if an integer is prime or not. Returns a bool.

func PairApproach

func PairApproach(n int) bool

PairApproach checks primality of an integer and returns a bool. More efficient than the naive approach as number of iterations are less.

func Sieve

func Sieve(in <-chan int, out chan<- int, prime int)

Sieve Sieving the numbers that are not prime from the channel - basically removing them from the channels

Types

This section is empty.

Jump to

Keyboard shortcuts

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