Skip to content

How to Check for Prime Numbers using Golang

If you need to check for Prime Numbers in Golang, then you can use the following method:

const n = 1212121 if big.NewInt(n).ProbablyPrime() { fmt.Println(n, "is prime") } else { fmt.Println(n, "is not prime") }
Code language: Go (go)

See also  How to Get the Instance Profile attached to an AWS EC2
Tags:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x