Multiply Down the Line

Factorial appears often in math and recursion practice: it is the product of all whole numbers from 1 to n. The function factorial receives a non-negative integer n and returns its factorial. Remember the special rule: the factorial of 0 is 1.

Примеры

Ввод
0
Вывод
1
Ввод
1
Вывод
1
Ввод
5
Вывод
120

Нужно реализовать

def factorial(n: int) -> int:

Теги

mathrecursion
PostgreSQLv16

Εδώ θα εμφανιστεί το αποτέλεσμα εκτέλεσης του κώδικα

Visible tests
1
Input
0
Expected1
2
Input
1
Expected1
3
Input
5
Expected120
4
Input
6
Expected720
5
Input
10
Expected3628800
6
Input
3
Expected6
Focus radio
Paused · SomaFM · Fluid