3
$\begingroup$

In this Python code, the function f is defined, which then immediately calls itself:

def f():     f() 

It's not very complicated, the first line defines the function, and the second line calls it. Therefore, once the function is initially called, it will be continued to be called forever, as there is no base case.

I just wanted to know if, from a mathematical standpoint, this was a real example of recursion (or at least met the mathematical definition of recursion)? While it may be rather pointless, I'm just curious as to whether or not it would actually be considered recursion.

  • 0
    What you wrote is indeed a recursive definition of a function.2012-02-23
  • 0
    There is no need for a base case in a recursive definition. A beautiful, tantalizing example is the definition of a *game* given by Conway in his extraordinary *On Games and Numbers*.2012-02-23
  • 3
    There's always a base case in a recursive definition, but sometimes the base case is so trivial no-one ever thinks about it. The base case for Conway's games is the empty game $\{ \quad \mid \quad \}$.2012-02-23

1 Answers 1