recursive.carbon 394 B

123456789101112131415161718192021
  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. //
  5. // NOAUTOUPDATE
  6. package ExplorerTest api;
  7. fn f(x: i32) -> i32 {
  8. if (x == 0) {
  9. return x;
  10. } else {
  11. return f(x - 1);
  12. }
  13. }
  14. fn Main() -> i32 {
  15. return f(2);
  16. }
  17. // CHECK:STDOUT: result: 0