boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

014-recursion.c (336B)


      1 /* tests/cc-e2e/14-recursion.c — recursive factorial.
      2  * Split from 01-kitchen-sink. */
      3 
      4 int factorial(int n) {
      5     if (n <= 1) return 1;
      6     return n * factorial(n - 1);
      7 }
      8 
      9 int test_recursion(void) { return factorial(5); }       /* 120 */
     10 
     11 int main(int argc, char **argv) {
     12     if (test_recursion() != 120) return 1;
     13     return 0;
     14 }