uaveiro-leci/1ano/fp/aula04/factorial.py

12 lines
255 B
Python
Raw Normal View History

2022-10-14 22:03:25 +00:00
def factorial(n):
total = 1
for x in range(1, n + 1):
total *= x
return total
def main():
n = int(input('Introduza um número: '))
print('O fatorial de {} é: {}'.format(n, factorial(n)))
2022-10-18 17:18:56 +00:00
if __name__ == "__main__":
main()