mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
376 B
26 lines
376 B
5 years ago
|
package main
|
||
|
|
||
|
import (
|
||
5 years ago
|
student "student"
|
||
|
|
||
|
"lib"
|
||
|
"lib/is"
|
||
5 years ago
|
)
|
||
|
|
||
|
func findPrevPrime(nb int) int {
|
||
|
if nb < 2 {
|
||
|
return 0
|
||
|
}
|
||
5 years ago
|
if is.Prime(nb) {
|
||
5 years ago
|
return nb
|
||
|
}
|
||
|
return findPrevPrime(nb - 1)
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
5 years ago
|
elems := append(lib.MultRandIntBetween(0, 99999), 5, 4, 1)
|
||
|
for _, elem := range elems {
|
||
5 years ago
|
lib.Challenge("FindPrevPrime", student.FindPrevPrime, findPrevPrime, elem)
|
||
|
}
|
||
|
}
|