func factorial(x : i32) -> i32: mut r = 1 while x > 0: r = r * x x = x - 1 return r