fn main() {
println!("{}", power(2, 3)); // 8
println!("{}", power(2, 4)); // 16
println!("{}", power(3, 2)); // 9
println!("{}", power(3, 3)); // 27
println!("{}", power(5, 4)); // 625
println!("{}", power(0, 7)); // 0
}
fn power(x: i32, y: i32) -> i32 {
if y == 0 {
return 1;
}
x * power(x, y - 1)
}
/*
run:
8
16
9
27
625
0
*/