9 September 2021

#$@%#@$@!$##@ Re-curse-ive Functions

Let us begin with I'm My Own Grandpa.

Really???? Can a function call itself? Yep. And here we go.

Nag a stupidhead

Print a List

Compute Binomial Coefficents

Global frame
      print_list  -------------------  CODE
      x  ----------------------------  Nyah Nyah Nyah
                                      |  |  |
print_list                            |  |  |
      x -------------------------------  |  |
      first -----------------------------   |
      rest ---------------------------------

print_list
      x ---- [Nyah Nyah]
      first-- Nyah
      rest -- [Nyah]

print_list 
      x ----- [Nyah]
      rest -- []
      first --  Nyah
print_list
      x ---- []

     c(n, k) = this is the number of subsets of size k in
               a set of size n.

     c(n, 0) = 1
     c(n, 1) = n
     c(n, n) = 1


     Set has elements 1...... n

     k is an integer, 0 <= k <= n

     How many subsets EXCLUDE 1?

     c(n-1, k)

     How many subsets INCLUDE 1?

     c(n-1, k-1)

     Conclusion

     c(n,k) = c(n=1, k-1) + c(n-1, k)


     c(4,2) = c(3,2) + c(3,1)
              c(2,1) c(2,2) + c(3,1)
                 2  +  1    +    3   = 6

     ABCD
     AB
     AC
     AD
     BC
     BD
     CD

     c(52,5)