fork download
  1. #!/usr/bin/python
  2. def factorial(n):
  3. if (type(n) == str):
  4. print "Factorial is only defined for integers"
  5. return -1
  6. elif n<0:
  7. print "Factorial is only defined for positive integers"
  8. return -1
  9. elif n==0:
  10. return 1
  11. else:
  12. return n * factorial(n-1)
  13.  
  14.  
  15.  
Success #stdin #stdout 0s 9024KB
stdin
factorial(3)
stdout
Standard output is empty