March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
15
Task/Ackermann-function/Rust/ackermann-function.rust
Normal file
15
Task/Ackermann-function/Rust/ackermann-function.rust
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// works for Rust 0.9
|
||||
fn main() {
|
||||
let a: int = ack(3, 4); // 125
|
||||
println!("{}", a.to_str());
|
||||
}
|
||||
|
||||
fn ack(m: int, n: int) -> int {
|
||||
if m == 0 {
|
||||
n + 1
|
||||
} else if n == 0 {
|
||||
ack(m - 1, 1)
|
||||
} else {
|
||||
ack(m - 1, ack(m, n - 1))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue