MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / randomPrime

Function randomPrime

cipher/rsa/rsa2.go:114–125  ·  view source on GitHub ↗

randomPrime returns two random prime numbers

()

Source from the content-addressed store, hash-verified

112
113// randomPrime returns two random prime numbers
114func randomPrime() (uint64, uint64) {
115 sieve := prime.SieveEratosthenes(1000)
116 sieve = sieve[10:] // remove first 10 prime numbers (small numbers)
117 index1 := rand.Intn(len(sieve))
118 index2 := rand.Intn(len(sieve))
119
120 for index1 == index2 {
121 index2 = rand.Intn(len(sieve))
122 }
123
124 return uint64(sieve[index1]), uint64(sieve[index2])
125}

Callers 1

NewFunction · 0.85

Calls 1

SieveEratosthenesFunction · 0.92

Tested by

no test coverage detected