How do I get the Math equation of Python Algorithm?
- by Gabriel
ok so I am feeling a little stupid for not knowing this, but a coworker asked so I am asking here: I have written a python algorithm that solves his problem. given x 0 add all numbers together from 1 to x.
def fac(x):
if x > 0:
return x + fac(x - 1)
else:
return 0
fac(10)
55
first what is this type of equation is this and what is the correct way to get this answer as it is clearly easier using some other method?