Here's an implementation of the factorial function in Rust:
main.rs106 chars8 linesThis function takes a u64 integer n and returns an u64 integer result. If n is zero, result is set to 1. Otherwise, result is set to n multiplied by the factorial of n-1.
You can call this function for any positive integer n and get the factorial of that number:
main.rs110 chars6 linesThis will output:
main.rs22 chars2 lines
gistlibby LogSnag