Last active
April 26, 2023 06:32
-
-
Save okayurisotto/110e8fefca5a7fb03d958bea57399955 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(module | |
(func (export "fibo") (param $index i32) (result i32) | |
(local $a i32) | |
(local $b i32) | |
(local $c i32) | |
(local.set $a (i32.const 1)) | |
(local.set $b (i32.const 0)) | |
(loop $fibo-loop | |
(if | |
(i32.ge_s (local.get $index) (i32.const 0)) | |
(then | |
(local.set $c (i32.add (local.get $a) (local.get $b))) | |
(local.set $a (local.get $b)) | |
(local.set $b (local.get $c)) | |
(local.set $index (i32.sub (local.get $index) (i32.const 1))) | |
(br $fibo-loop) | |
) | |
) | |
) | |
(local.get $b) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment