Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn factorial (n: u32) -> u32 {
- if n==0{
- return 1;
- }
- let mut product =1;
- for i in 1..=n{
- product *=dbg! (i);
- }
- product
- }
- fn main(){
- let n=-1;
- println! ("{n}! ={}",factorial(n));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement