Of course it would be more typical to define some state for objects of the class, and perhaps also an inheritance hierarchy. Save this in
Run it from the command line:
Two other standard Python operators are the "getitem" operator [ ], and the "call" operator ( ). These can be implemented for any user-defined class:
I wrote a simple class to implement the factorial function that uses the call operator. This class keeps the values it currently knows in a list. (Apparently, this technique is called memoization). If we knew that we only wanted the last value, it would be better not to do this..
25,000 factorial has nearly 100,000 digits!