Last active
December 18, 2019 14:53
-
-
Save rayinla/99cbadd70e5bdad5a42ded4405f1f297 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
#[no_mangle] | |
pub extern fn factorialize(mut num: i64) -> i64 { | |
if num == 0 || num == 1 { | |
return 1; | |
} | |
let mut cnt = num - 1; | |
loop { | |
if cnt < 1 { | |
break; | |
} | |
num = num * cnt; | |
cnt = cnt -1; | |
} | |
return num; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment