fork download
  1. def Square(x):
  2. return SquareHelper(abs(x), abs(x))
  3.  
  4. def SquareHelper(n, x):
  5. if n == 0:
  6. return 0
  7. return SquareHelper(n-1, x) + x
  8.  
  9. print Square(5)
  10. print Square(-2)
  11. print Square(1)
  12. print Square(-3)
  13. print Square(7)
  14. print Square(-9)
Success #stdin #stdout 0.02s 7108KB
stdin
Standard input is empty
stdout
25
4
1
9
49
81