If one calls count_n(0) wouldn't the result be 0?
Shouldn't there be a check at the beginning of the function like
pub fn count_n(mut n: i32) -> i32 {
// count the digits in the number
if n == 0 {
return 1;
}
let mut count = 0;
if n <0 {
n=n*-1
}
while n>0 {
n=n/10;
count = count +1;
}
count
}
If one calls count_n(0) wouldn't the result be 0?
Shouldn't there be a check at the beginning of the function like
```rust
pub fn count_n(mut n: i32) -> i32 {
// count the digits in the number
if n == 0 {
return 1;
}
let mut count = 0;
if n <0 {
n=n*-1
}
while n>0 {
n=n/10;
count = count +1;
}
count
}
```
If one calls count_n(0) wouldn't the result be 0? Shouldn't there be a check at the beginning of the function like
I fix it THNX for you