diff --git a/subjects/count_factorial_steps/README.md b/subjects/count_factorial_steps/README.md new file mode 100644 index 00000000..63a5959a --- /dev/null +++ b/subjects/count_factorial_steps/README.md @@ -0,0 +1,39 @@ +## 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. + +```rust +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: + +```rust +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: + +```console +$ cargo run +The factorial steps of 720 = 6 +The factorial steps of 13 = 0 +The factorial steps of 6 = 3 +```