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.
28 lines
574 B
28 lines
574 B
5 years ago
|
package main
|
||
5 years ago
|
|
||
|
import (
|
||
5 years ago
|
"math"
|
||
|
|
||
5 years ago
|
"./student"
|
||
5 years ago
|
)
|
||
|
|
||
5 years ago
|
func iterativePower(nb int, power int) int {
|
||
|
if power < 0 {
|
||
|
return 0
|
||
|
}
|
||
|
result := math.Pow(float64(nb), float64(power))
|
||
|
return int(result)
|
||
|
}
|
||
|
|
||
5 years ago
|
func main() {
|
||
5 years ago
|
i := 0
|
||
|
for i < 30 {
|
||
5 years ago
|
nb := lib.RandIntBetween(-8, 8)
|
||
|
power := lib.RandIntBetween(-10, 10)
|
||
5 years ago
|
lib.Challenge("IterativePower", student.IterativePower, iterativePower, nb, power)
|
||
5 years ago
|
i++
|
||
|
}
|
||
5 years ago
|
lib.Challenge("IterativePower", student.IterativePower, correct.IterativePower, 0, 0)
|
||
|
lib.Challenge("IterativePower", student.IterativePower, correct.IterativePower, 0, 1)
|
||
5 years ago
|
}
|