• Question: What exactly is recursion?

    Asked by knighto to Willem on 7 Mar 2014.
    • Photo: Willem Heijltjes

      Willem Heijltjes answered on 7 Mar 2014:


      Recursion is a way of programming (or doing mathematics). It consists of three steps:
      1. Do something.
      2. Are we done? Then give the answer.
      3. We’re not done? Then start from the top (in a slightly different way)!
      For example, here is a recipe for whisking egg whites:
      1. Whisk for a bit.
      2. Do we have a foam with stiff peaks? We’re done.
      3. No stiff peaks yet? Start from the top!

Comments