Go isPrime()

1 개요[ | ]

Go isPrime()
package main

import (
	"fmt"
	"math/big"
)

func isPrime(n int) bool {
	return big.NewInt(int64(n)).ProbablyPrime(0)
}

func main() {
	for i := 0; i < 30; i++ {
		if isPrime(i) {
			fmt.Printf("%d ", i) // 2 3 5 7 11 13 17 19 23 29
		}
	}
}

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}