mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nprimo
5fd392a741
|
2 years ago | |
---|---|---|
.. | ||
README.md | 2 years ago |
README.md
count_factorial_steps
Instructions
Create a function named count_factorial_steps
that receives a factorial number and counts how many multiplications are necessary to have this number.
If the argument is not a factorial or == 0 || 1 then the function should return 0.
fn count_factorial_steps(factorial: u64) -> u64 {
}
As a reminder, the factorial of a number is the product of all the integers from 1 to that number.
Example: the factorial of 6 (written 6!) is 1 * 2 * 3 * 4 * 5 * 6 = 720.
Usage
Here is a possible program to test your function:
use count_factorial_steps::count_factorial_steps;
fn main() {
println!("The factorial steps of 720 = {}", count_factorial_steps(720));
println!("The factorial steps of 13 = {}", count_factorial_steps(13));
println!("The factorial steps of 6 = {}", count_factorial_steps(6));
}
And its output:
$ cargo run
The factorial steps of 720 = 6
The factorial steps of 13 = 0
The factorial steps of 6 = 3