Skip to content

Instantly share code, notes, and snippets.

@rayinla
Last active December 18, 2019 14:53
Show Gist options
  • Save rayinla/99cbadd70e5bdad5a42ded4405f1f297 to your computer and use it in GitHub Desktop.
Save rayinla/99cbadd70e5bdad5a42ded4405f1f297 to your computer and use it in GitHub Desktop.
#[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