Skip to content

Commit f473563

Browse files
committed
doc: add comments
Loop structure: While. Factorial calculation.
1 parent 69d2f3b commit f473563

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ex060.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#EN- Loop structure: While
2+
#Factorial Calculation
13
#60- Write a program that reads any number and displays its factorial.
24
# just in four lines
35
'''from math import factorial
@@ -6,7 +8,7 @@
68
print(f'The factorial of {number}! is {result}')'''
79

810
# or you can make it prettier
9-
number = int(input('Enter a number:'))
11+
'''number = int(input('Enter a number:'))
1012
counter = number
1113
fat = 1
1214
print(f'Calculating {number}! =', end= ' ')
@@ -15,4 +17,11 @@
1517
print(' x ' if counter > 1 else ' = ', end=' ')
1618
fat *= counter
1719
counter -= 1
18-
print(f'{fat}.')
20+
print(f'{fat}.')'''
21+
22+
#PT- Estrutura de repetição: While
23+
#Cálculo do Fatorial
24+
#60: Faça um programa que leia um número qualquer e mostre o seu fatorial. Exemplo:
25+
from math import factorial
26+
numero = int(input("Digite um número:"))
27+
print(f'O fatorial de {numero} é {factorial(numero)}.')

0 commit comments

Comments
 (0)