<problem>
Write a function `factorial(n:int) -> int` that computes the factorial n! of a natural number n, which is defined mathematically as:

$0! = 1$
$n! = n \times (n - 1)!$

Additionally, if the input integer n is negative the function should return 0.

## Example Cases:
```
factorial(-1) => 0
factorial(0) => 1
factorial(1) => 1
factorial(2) => 2
factorial(3) => 6
factorial(4) => 24
factorial(5) => 120
```
</problem>
<bug_code>
1. def factorial(n):
2.        if n < 0:
3.                return 0
4.        fact = 1
5.        for i in range(n):
6.                fact = fact * i
7.        return fact
</bug_code>
<bug_desc>
On line 6, `fact` is multiplied with 0 in the first iteration of the for loop. Consequently, at every iteration fact stays equal with 0 instead of being updated to be equal with factorial of `(i + 1)`. Therefore, the function will return 0, irrespective of n

</bug_desc>
<bug_fixes>
Replace `i` with `(i + 1)` in line 6.
Replace `range(n)` with `range(1, n + 1)` in line 5.
</bug_fixes>
<unit_tests>
assert factorial(-1) == 0
assert factorial(0) == 1
assert factorial(1) == 1
assert factorial(2) == 2
assert factorial(3) == 6
assert factorial(4) == 24
assert factorial(5) == 120
</unit_tests>
<stu_desc>

</stu_desc>
<dialogue>
User: Hi! I implemented the factorial function but it doesn’t work and I do not know why. Can you help?
Assistant: Sure. Can you tell me for what values of `n` it fails and what values it returns in those cases?
User: For `n = 1` or larger it returns the same value, 0.
Assistant: Let’s see what happens when `n` is 1. What is the first value that is assigned to variable `i` in line 5?
	<alt>Let’s see what happens when `n` is 1. Before line 6 is evaluated in the first iteration of the for loop, what are the values of the variables `fact` and `i`?
	<alt>Let’s see what happens when `n` is 1. Can you insert a new line between lines 5 and 6 that prints the values of the variables `fact` and `i`?
	<alt>Let’s see what happens when `n` is 1. What does `range(n)` do when `n` is 1?
	<alt>Can you tell me what `range(n)` does?
User: Aaah, I understand! The first value assigned to `i` will be 0, because range by default starts at 0.
	<alt>The first value assigned to `i` will be 1.
	<alt>Oh! `i` is not declared before the for loop is created, maybe that causes this issue.
Assistant: That’s right. So, what happens when `i` is 0?
	<alt>Correct. Given that `i` is 0, what happens when line 6 is evaluated?
User: We go into the for loop and compute `fact`.
	<alt>The value of `fact` will be 0 because `i` is 0. I think I got it `fact` will always be because of this. I need to change the `range` call to start at 1 instead of 0 and end at `n+1` instead of `n`.
Assistant: That's right. Given that `i` is 0, what will the value of `fact` be after line 6 is executed?
User: Aha! I see what is happening. `fact` is always 0 because `i` is 0 in the first iteration of the for loop. I need to change the range to start at 1 instead of 0 and end at `n+1` instead of `n`.  Thanks! I think I got it now.
<code>
1. def factorial(n):
2.        if n < 0:
3.                return 0
4.        fact = 1
5.        for i in range(1, n + 1):
6.                fact = fact * i
7.        return fact
</code>
Assistant: I am glad I could help. If you have any other questions, please let me know.
User: Thank you!
</dialogue>