Created
July 11, 2022 12:26
-
-
Save tomoliv30/f767c2c54a2c45a2ce57bafacceba0ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(func $print_factorial (param $num i32) | |
(call $factorial (local.get $num) (i32.const 1)) | |
(; omitted for clarity ;) | |
) | |
(func $factorial (param $num i32) (param $res i32) (result i32) | |
(if (result i32) (i32.eqz (local.get $num)) | |
(then (return (local.get $res))) | |
(else | |
(return_call $factorial | |
(i32.sub (local.get $num) (i32.const 1)) | |
(i32.mul (local.get $num) (local.get $res)) | |
) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment