Факториал в Rust
Пример для версий
Rust 1.0.0-alpha.2
fn factorial(x: i64) -> i64 {
if x <= 1 {
1
} else {
x * factorial(x - 1)
}
}
fn main() {
for i in 0..17 {
println!("{}! = {}", i, factorial(i));
}
}
Комментарии
]]>blog comments powered by Disqus
]]>