I'm programming a calculator application using Python 3, and everything functions fine (I think), except when I attempt to use the my double_factorial() function. If I enter a number higher than 3, the program doesn't output anything and my computer overheats (I use a Macbook Pro, fully customized to be as powerful as possible). This is either a straight up computer issue, or a computer issue because of something wrong with my code. Is there anything wrong with my code that I might not be able to spot as a beginner? (note: I'm only posting the relevant sections):
def add(a,b):
return(a + b)
def subtract(a,b):
return(a - b)
def multiply(a,b):
counter = 0
for i in range(a):
counter = add(counter, b)
return(counter)
def divide(a,b):
quotient = 0
while a >= b:
quotient = add(quotient, 1)
a = subtract(a,b)
return (quotient, a)
def factorial(a):
c = 1
while a > 1:
c = multiply(c,a)
a = subtract(a,1)
return(c)
def double_factorial(a):
og = factorial(a)
return factorial(og)
def equation():
d = None
print("Valid operations: +, -, *, /, !, !!, =")
c = eval(input("Integer: "))
while d != "=":
d = input("Operation: ")
if d in ('+', '-', '*', '/', '!', '!!', '='):
if d == "+":
c = add(c, eval(input("Integer: ")))
elif d == "-":
c = subtract(c, eval(input("Integer: ")))
elif d == "*":
c = multiply(c, eval(input("Integer: ")))
elif d == "/":
c = divide(c, eval(input("Integer: ")))
elif d == "!":
c = factorial(c)
elif d == "!!":
c = double_factorial(c)
elif d != "=":
print("invalid")
print(str(c))