#Maple Code for Recitation 5 #HelpReci5:=proc(): print(` p(n), d(n), e(n), a(n) `): #p(n): the number of permutations of {1, ...,n} p:=proc(n) option remember: if n=0 then 1: else n*p(n-1): fi: end: #A142 #d(n) The number of derangements of {1, .., n} #A166 d:=proc(n) option remember: if n=0 then 1: else n*d(n-1)+ (-1)^(n): fi: end: #e(n): Another recurrence that happened to be in the OEIS e:=proc(n) option remember: if n=1 then 1: else (n-1)*d(n-1)+ n-1: fi: end: #a(n): The same sequence using the HOMOG. 3-rd order #recurrence given in the OEIS a:=proc(n) option remember: if n=0 then 1: elif n=1 then 2: elif n=2 then 6: elif n=3 then 21: else (n+1)*a(n-1) - (2*n-3)*a(n-2) + (n-3)*a(n-3): fi: end: