rust/src/test/run-pass/fact.rs
2012-08-23 11:14:14 -07:00

29 lines
387 B
Rust

// -*- rust -*-
fn f(x: int) -> int {
// debug!("in f:");
log(debug, x);
if x == 1 {
// debug!("bottoming out");
return 1;
} else {
// debug!("recurring");
let y: int = x * f(x - 1);
// debug!("returned");
log(debug, y);
return y;
}
}
fn main() {
assert (f(5) == 120);
// debug!("all done");
}