When I try this at the REPL in Python 3.3:
>>> def fact(n):
... res = 1
... while n > 1:
... res *= n
... n -= 1
... return res
...
>>> print fact(23)
I get SyntaxError: invalid syntax
. Why?
In python 3.x print is a function. Try print(fact(23))
instead.