mirror of https://github.com/01-edu/public.git
Xavier Petit
4 years ago
committed by
xpetit
5 changed files with 11 additions and 28 deletions
@ -1,24 +1,8 @@
|
||||
package correct |
||||
|
||||
import "math" |
||||
|
||||
func isPrime(value int) bool { |
||||
if value < 2 { |
||||
return false |
||||
} |
||||
limit := int(math.Floor(math.Sqrt(float64(value)))) |
||||
i := 2 |
||||
for i <= limit { |
||||
if value%i == 0 { |
||||
return false |
||||
} |
||||
i++ |
||||
} |
||||
return true |
||||
} |
||||
func FindNextPrime(value int) int { |
||||
if isPrime(value) { |
||||
return value |
||||
func FindNextPrime(nb int) int { |
||||
if isPrime(nb) { |
||||
return nb |
||||
} |
||||
return FindNextPrime(value + 1) |
||||
return FindNextPrime(nb + 1) |
||||
} |
||||
|
Loading…
Reference in new issue