Go isPrime()

Jmnote (토론 | 기여)님의 2023년 4월 27일 (목) 23:36 판 (→‎같이 보기)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

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 }}