Fri Jan 13, 2012 6:49 pm by blast_hardcheese
sumit kumar wrote:actually first i want to add two numbers and then i want to find factorial of sum of two numbers.
Probably better to break these up into component pieces:
- Code:
def add(a,b):
c = a + b
return c
def factorial(x):
fact=1
while x>0:
fact=fact*x
return fact
Once we do that, we can check to see if the functions actually do what they should do:
- Code:
print "Add:", add(1,2)
print "Fact:", factorial(3)
We see the "3" is printed from add, but we never see the factorial function finish. This is because of an infinite loop in factorial(), see if you can find it

If you can't, I'll point it out