fun_recur.carbon 320 B

123456789101112131415
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. fn f(x: i32) -> i32 {
  5. if (x == 0) {
  6. return x;
  7. } else {
  8. return f(x - 1);
  9. }
  10. }
  11. fn main() -> i32 {
  12. return f(2);
  13. }