mod utils; static TEST_BASE:f64 = 0.9f64; fn exponentiation(base:f64, powerArg:isize) -> f64 { assert!(powerArg >= 0, "powerArg >= 0"); let mut power:isize = powerArg; let mut result:f64 = 1; while power > 0 { result *= base; power -= 1; } return result; } fn main() { { let mut p:isize = 10; while p >= -1 { println!("{}", format!("{0:f} ^ {1:d} = {2:f}", TEST_BASE, p, exponentiation(TEST_BASE, p))); p += -1; } } }