Tree of SCIENCE!!! #4

Here’s where things on the Tree of SCIENCE!!! start to get more interesting, and somewhat more obscure:

i-3f09ecf95ddcb93471385cfa05fafe68-sm_tree.jpg

Yes, that’s a small wooden Christmas tree ornament hanging on our full-size Christmas tree. What’s this have to do with SCIENCE!!!? Well, obviously, it represents recursion.

recursion, as you know Bob, is an extremely useful technique in computer programming, whereby you define a function in terms of itself. The classic example of this is the factorial function:

n! = 1*2*3*…*(n-1)*(n)

You can write a program to calculate the factorial of a number by defining a function f(n) that has two possible outputs:

  • If n=1, it returns f(1)=1.
  • If n>2, it returns f(n)=n*f(n-1).

If you spend a few minutes thinking about what this does for a specific number– 17, say, because it’s the mystical number– you can convince yourself that it will, in fact, give you the factorial for any n.

Recursion lets you write extremely short programs to do infinitely complicated tasks, and as such is an invaluable tool for computer programming. And, of course, it’s almost impossible to do science these days without computers.

Thus, recursion gets a place on the Tree of SCIENCE!!!