prime: github.com/afshin/prime Index | Examples | Files

package prime

import "github.com/afshin/prime"

Package prime contains a helper function to check whether an integer is prime. In the future, it may contain other functions, but the API will remain backward-compatible.

Index

Examples

Package Files

prime.go

func IsPrime Uses

func IsPrime(candidate uint64) bool

IsPrime checks if candidate is a prime number.

Code:

var candidate uint64 = 5
if prime.IsPrime(candidate) {
    fmt.Println("Five is prime.")
} else {
    fmt.Println("Five is not prime.")
}

Output:

Five is prime.

Updated 2016-07-30. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).