-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfatorial-calculator.py
More file actions
44 lines (35 loc) · 877 Bytes
/
fatorial-calculator.py
File metadata and controls
44 lines (35 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
""""
Variáveis:
a = fatorial de b
b = número que se deseja ser calculado o fatorial
c = variável contadora
"""
# Boas-vindas:
print ("\nBem-vindo(a) à Calculadora de Fatorial do Raphael\n")
a = ""
while a != "s":
# Entrada:
print ("*para sair, digite 's'* \nEntre com o número inteiro para fatorial:\n")
while True:
try:
a = input ()
if a == "s":
break
a = int(a)
break
except ValueError or TypeError:
print ("Entre com um número inteiro!")
if a == "s":
break
# Cálculo:
b = a
c = a - 1
for c in range (int(c), 1, -1):
a = a * c
# Saída:
try:
print ("\nO fatorial de", b, "é", a)
except ValueError:
print ("excedente ao limite (4300 dígitos) suportado :/")
print ("")
print ("\nAdeus")