####################################################################### ### PART C: ALL FORMULAS AS MAPLE PROGRAMS. ####################################################################### > restart; with(combstruct): with(combinat): > > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A000012(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 2 to 9 do FibonacciNumbers(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do SumOfPartitionNumbers(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do PowersOf2(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A000085(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do BellNumbers(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A000124(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A000142(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A000217(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do PowersOf3(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A000262(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A000292(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do PowersOf4(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A000312(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A000326(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A000330(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do NumberOfPreferentialArrangements(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do LAHNumbers(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A002627(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A005651(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do BinomialCoefficients(dummy,2) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A007526(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A007841(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do Stirling1Numbers(dummy,2) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do Stirling2Numbers(dummy,2) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do EulerNumbers(dummy,2) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A014968(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A050351(dummy,2) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A082579(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A093694(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A098407(dummy) end do; > > read("E:/Eigene Dateien/Formel/Formelsammlung.mpl"): > for dummy from 1 to 9 do A104533(dummy) end do; > A000012 := proc(n::integer) # Procedure A000012 calculates the sum (taken over all partitions of n) of the products q_{1/t 1/m!}. # q_{1/t 1/m!} = the reciprocal of the product of all parts of a partition times # the reciprocal of the product of the multiplicities of these parts. # A000012(1) = 1, A000012(6) = 81, A000012(9) = 1. # Procedure A000012 uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 16.10.2006 local A000012,D,T,i,j,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities, Term1,Term2; ListOfPartitions:=partition(n); A000012 := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); #A000012 := A000012+(1/mul(op(j,ASinglePartition),j=1..T))*(1/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D)); Term1:=(1/mul(op(j,ASinglePartition),j=1..T)); Term2:=(1/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D)); A000012:=A000012+Term1*Term2; #print(i,Term1,Term2,Term1*Term2,A000012); od; print(n,A000012); end proc; FibonacciNumbers := proc(n::integer) # Procedure FibonacciNumbers calculates the Fibonacci numbers F(n) (= A000045) for n=2,3,4,... # F = Fibonacci number, F(3) = 2, F(6) = 8, F(9) = 34. # Procedure FibonacciNumbers uses the integer partitions of n with all parts less or equal k=2. # E.g. [1,1,1,2] is a partition of n=5 with four parts, all less or equal k=2. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 14.10.2006 local F,D,T,i,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; if n < 2 then print("Use FibonacciNumers for n=2,3,4... only!"); break; fi; ListOfPartitions:=partition(n,2); F := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); F := F+T!/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D); od; print(n,F); end proc; SumOfPartitionNumbers := proc(n::integer) # Procedure SumOfPartitionNumbers calculates the sum of the partition numbers A000070(n). # A000070 = sum of partition numbers, A000070(1) = 1, A000070(6) = 19, A000070(9) = 67. # Procedure SumOfPartitionNumbers uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 17.10.2006 local A000070,D,i,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=partition(n); A000070 := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); A000070 := A000070 + D; od; print(n,A000070); end proc; PowersOf2 := proc(n::integer) # Procedure PowersOf2 calculates the powers of 2 = 2^n (= A000079). # a = 2^n, a(1) = 2, a(2)=4, a(5) = 32. # Procedure PowersOf2 uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 14.10.2006 local a,D,T,i,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=partition(n); a := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); a := a+(T!/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D)); od; print(n,a); end proc; A000085 := proc(n::integer) # Procedure A000085 calculates number of self-inverse permutations on n letters, # also known as involutions; number of Young tableaux with n cells.. # A000085(1) = 1, A000085(6) = 76, A000085(9) = 2620. # Procedure A000085 uses the integer partitions of n with no part greater than k=2 # but with at least one part equal to k=2, # e.g. partition(7,2) gives [2, 1, 1, 1, 1, 1], [2, 2, 1, 1, 1], [2, 2, 2, 1]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 02.11.2006 local A000085,D,T,i,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=ListIntegerPtns(n,2); A000085 := 1; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); A000085 := A000085+(n!/mul(op(j,ASinglePartition)!,j=1..T))*(1/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D)); od; print(n,A000085); end proc; # ##################################################################### # ##################################################################### ListIntegerPtns := proc (n, k) # Authors: # Herbert S. Wilf and Joanna Nordlicht, # Source: # Lecture Notes "East Side West Side,..." # University of Pennsylvania, USA, 2002. # Avalible at: http://www.cis.upenn.edu/~wilf/lecnotes.html # Berechnet die Partitionen von *** n *** # mit mindestens einem Summanden gleich *** k *** # und keinem Summandem groesser als **** k ***. local east, west, eastop, westop; option remember; eastop := proc (y) options operator, arrow; applyop(proc (t) options operator, arrow; t+1 end proc, 1, y) end proc; westop := proc (y, j) options operator, arrow;[j, op(y)] end proc; if n <= 0 or k <= 0 or n < k then RETURN([]) elif n = 1 then RETURN([[1]]) else east := ListIntegerPtns(n-1, k-1); west:= ListIntegerPtns(n-k, k); RETURN([op(map(eastop,east)),op(map(westop, west, k))]) end if end proc; # ################################################################### # #################################################################### CatalanNumbers := proc(n_in::integer) # Procedure CatalanNumbers calculates the Catalan numbers K (= A000108). # E.g. K(1) = 1, K(6) = 132, K(9) = 4862. # Procedure CatalanNumbers uses the integer partitions of n=2(n_in+1) into n_in+1 parts. # E.g. for n_in=3 we have n=2*(3+1)=7 and k=3 and [1,1,5], [1,2,4], [1,3,3]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 06.11.2006 local Ka,D,T,i,k,n,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; n := 2*n_in+1; k := n_in+1; ListOfPartitions:=PartitionList(n,k); Ka := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); Ka := Ka + (k!/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D)); od; Ka:=Ka/(n_in+1); print(n_in,Ka); end proc; # ##################################################################### # ##################################################################### PartitionList := proc (n, k) # Authors: # Herbert S. Wilf and Joanna Nordlicht, # Source: # Lecture Notes "East Side West Side,..." # University of Pennsylvania, USA, 2002. # Avalible at: http://www.cis.upenn.edu/~wilf/lecnotes.html # Berechnet die Partitionen von *** n *** mit *** k *** Summanden. local East, West; if n < 1 or k < 1 or n < k then RETURN([]) elif n = 1 then RETURN([[1]]) else if n < 2 or k < 2 or n < k then West := [] else West := map(proc (x) options operator, arrow; [op(x), 1] end proc, PartitionList(n-1, k-1)) end if; if k <= n-k then East := map(proc(y) options operator, arrow; map(proc (x) options operator, arrow; x+1 end proc, y) end proc, PartitionList(n-k, k)) else East := [] end if; RETURN([op(West), op(East)]) end if end proc; # ##################################################################### # ##################################################################### BellNumbers := proc(n::integer) # Procedure BellNumbers calculates the Bell numbers B(n) (= A000110). # B = Bell number, B(1) = 1, B(6) = 203, B(9) = 21147. # Procedure BellNumbers uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 14.10.2006 local B,D,T,i,j,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=partition(n); B := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); B := B+(n!/mul(op(j,ASinglePartition)!,j=1..T))*(1/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D)); od; print(n,B); end proc; A000124 := proc(n_in::integer) # Procedure A000124 calculates the Central polygonal numbers (the Lazy Caterer's sequence): n(n+1)/2 + 1. # A000124(1) = 2, A000124(6) = 22, A000124(9) = 46. # Procedure A000124 uses the n integer partitions of n of the form [1,1,...,1,n-m] where m is the number of "1"s within the partition. # E.g. for n = 5 we use the following 5 partitions: [11111], [1112], [1,1,3], [1,4], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 20.10.2006 local A000124,D,T,n,k,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; n := n_in + 1; A000124 := 0; for k from 1 to n do ListOfPartitions:=ListIntegerPtns(n,k); ASinglePartition := ListOfPartitions[1]; #print( ListOfPartitions[1]); T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); A000124 := A000124 + T!/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D); od; print(n,A000124); end proc; # ##################################################################### # ##################################################################### ListIntegerPtns := proc (n, k) # Authors: # Herbert S. Wilf and Joanna Nordlicht, # Source: # Lecture Notes "East Side West Side,..." # University of Pennsylvania, USA, 2002. # Avalible at: http://www.cis.upenn.edu/~wilf/lecnotes.html # Berechnet die Partitionen von *** n *** # mit mindestens einem Summanden gleich *** k *** # und keinem Summandem groesser als **** k ***. local east, west, eastop, westop; option remember; eastop := proc (y) options operator, arrow; applyop(proc (t) options operator, arrow; t+1 end proc, 1, y) end proc; westop := proc (y, j) options operator, arrow;[j, op(y)] end proc; if n <= 0 or k <= 0 or n < k then RETURN([]) elif n = 1 then RETURN([[1]]) else east := ListIntegerPtns(n-1, k-1); west:= ListIntegerPtns(n-k, k); RETURN([op(map(eastop,east)),op(map(westop, west, k))]) end if end proc; # ################################################################### # #################################################################### A000142 := proc(n_in::integer) # Procedure A000142 calculates the Factorial numbers: n! = 1*2*3*4*...*n. # A000142(1) = 1, A000142(6) = 720, A000142 (9) = 362880. # Procedure A000217 uses the integer partitions of n into k=2 parts. # E.g. for n_in=6 we have [1,5], [4,2], [3,3]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Änderung: 04.11.2006 local A000142,n,D,i,k,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; n:=n_in+1; k := 2; A000142 := 1; ListOfPartitions:=PartitionList(n,k); for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); A000142:= A000142 * mul(op(1,op(s,ListOfDifferentPartsAndMultiplicities)),s=1..D); od; print(n,A000142); end proc; # ##################################################################### # ##################################################################### PartitionList := proc (n, k) # Authors: # Herbert S. Wilf and Joanna Nordlicht, # Source: # Lecture Notes "East Side West Side,..." # University of Pennsylvania, USA, 2002. # Avalible at: http://www.cis.upenn.edu/~wilf/lecnotes.html # Berechnet die Partitionen von *** n *** # mit *** k *** Summanden. local East, West; if n < 1 or k < 1 or n < k then RETURN([]) elif n = 1 then RETURN([[1]]) else if n < 2 or k < 2 or n < k then West := [] else West := map(proc (x) options operator, arrow; [op(x), 1] end proc, PartitionList(n-1, k-1)) end if; if k <= n-k then East := map(proc(y) options operator, arrow; map(proc (x) options operator, arrow; x+1 end proc, y) end proc, PartitionList(n-k, k)) else East := [] end if; RETURN([op(West), op(East)]) end if end proc; # ##################################################################### # ##################################################################### A000217 := proc(n::integer) # Procedure A000217 calculates the Triangular numbers: a(n) = C(n+1/2) = n(n+1)/2 = 0+1+2+...+n.. # A000217(1) = 1, A000217 (6) = 21, A000217 (9) = 45. # Procedure A000217 uses the integer partitions of n into k=2 parts. # E.g. for n_in=6 we have n=8 and [6, 1, 1], [5, 2, 1], [4, 3, 1], [4, 2, 2], [3, 3, 2]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Änderung: 04.11.2006 local A000217,D,i,k,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; k := 2; A000217 := 0; ListOfPartitions:=PartitionList(n,k); for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); A000217 := A000217 + add(op(1,op(s,ListOfDifferentPartsAndMultiplicities)),s=1..D); od; print(n,A000217); end proc; # ##################################################################### # ##################################################################### PartitionList := proc (n, k) # Authors: # Herbert S. Wilf and Joanna Nordlicht, # Source: # Lecture Notes "East Side West Side,..." # University of Pennsylvania, USA, 2002. # Avalible at: http://www.cis.upenn.edu/~wilf/lecnotes.html # Berechnet die Partitionen von *** n *** # mit *** k *** Summanden. local East, West; if n < 1 or k < 1 or n < k then RETURN([]) elif n = 1 then RETURN([[1]]) else if n < 2 or k < 2 or n < k then West := [] else West := map(proc (x) options operator, arrow; [op(x), 1] end proc, PartitionList(n-1, k-1)) end if; if k <= n-k then East := map(proc(y) options operator, arrow; map(proc (x) options operator, arrow; x+1 end proc, y) end proc, PartitionList(n-k, k)) else East := [] end if; RETURN([op(West), op(East)]) end if end proc; # ##################################################################### # ##################################################################### A000217b := proc(n_in::integer) # Procedure A000217 calculates the Triangular numbers: a(n) = C(n+1/2) = n(n+1)/2 = 0+1+2+...+n.. # A000217(1) = 1, A000217 (6) = 21, A000217 (9) = 45. # Procedure A000217 uses the integer partitions of n=n_in+2 into k=3 parts. # E.g. for n_in=6 we have n=8 and [6, 1, 1], [5, 2, 1], [4, 3, 1], [4, 2, 2], [3, 3, 2]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 27.10.2006 local A000217,D,T,n,i,k,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities, Term1,Term2; n := n_in + 2; k := 3; A000217 := 0; ListOfPartitions:=PartitionList(n,k); for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); Term1 := T!; Term2 := mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D); A000217 := A000217 + Term1/Term2; print(ListOfPartitions[i],Term1,Term2,Term1/Term2); od; print(n_in,A000217); end proc; # ##################################################################### # ##################################################################### PartitionList := proc (n, k) # Authors: # Herbert S. Wilf and Joanna Nordlicht, # Source: # Lecture Notes "East Side West Side,..." # University of Pennsylvania, USA, 2002. # Avalible at: http://www.cis.upenn.edu/~wilf/lecnotes.html # Berechnet die Partitionen von *** n *** # mit *** k *** Summanden. local East, West; if n < 1 or k < 1 or n < k then RETURN([]) elif n = 1 then RETURN([[1]]) else if n < 2 or k < 2 or n < k then West := [] else West := map(proc (x) options operator, arrow; [op(x), 1] end proc, PartitionList(n-1, k-1)) end if; if k <= n-k then East := map(proc(y) options operator, arrow; map(proc (x) options operator, arrow; x+1 end proc, y) end proc, PartitionList(n-k, k)) else East := [] end if; RETURN([op(West), op(East)]) end if end proc; # ##################################################################### # ##################################################################### PowersOf3 := proc(n::integer) # Procedure PowersOf3 calculates the powers of 3 = 3^n (= A000244) # a = 3^n, a(1) = 3, a(2)=9, a(5) = 243. # Procedure PowersOf3 uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 14.10.2006 local a,D,T,i,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=partition(n); a := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); a := a+(T!/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D))*2^(T-1); od; print(n,a); end proc; A000262 := proc(n::integer) # Procedure A000262 calculates the number of sets of lists. # A000262(1) = 1, A000262(6) = 4051, a(9) = 4596553. # Procedure A000262 uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 21.10.2006 local A000262,D,T,i,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=partition(n); A000262 := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); A000262 := A000262+(1/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D)); od; A000262 := n! * A000262; print(n,A000262); end proc; A000290 := proc(n::integer) # Procedure A000290 calculates the squares: a(n) = n^2. . # A000290(1) = 1, A000290(6) = 36, A000290(9) = 81. # Procedure A000290 uses the n integer partitions of n of the form [1,n-1]. # E.g. for n = 5 we use the partition [1,4]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 10.11.2006 local A000290,m,i,j,k,ASinglePartition,ListOfPartitions; A000290 := 0; k:=2; m:=2; for i from 1 to n do ListOfPartitions:=PartitionList(m,k); ASinglePartition := ListOfPartitions[1]; #print( ListOfPartitions[1]); A000290 := A000290 + mul(op(j,ASinglePartition),j=1..k); m:=m+2; od; print(n,A000290); end proc; # ##################################################################### # ##################################################################### PartitionList := proc (n, k) # Authors: # Herbert S. Wilf and Joanna Nordlicht, # Source: # Lecture Notes "East Side West Side,..." # University of Pennsylvania, USA, 2002. # Avalible at: http://www.cis.upenn.edu/~wilf/lecnotes.html # Berechnet die Partitionen von *** n *** # mit *** k *** Summanden. local East, West; if n < 1 or k < 1 or n < k then RETURN([]) elif n = 1 then RETURN([[1]]) else if n < 2 or k < 2 or n < k then West := [] else West := map(proc (x) options operator, arrow; [op(x), 1] end proc, PartitionList(n-1, k-1)) end if; if k <= n-k then East := map(proc(y) options operator, arrow; map(proc (x) options operator, arrow; x+1 end proc, y) end proc, PartitionList(n-k, k)) else East := [] end if; RETURN([op(West), op(East)]) end if end proc; # ##################################################################### # ##################################################################### A000292 := proc(n_in::integer) # Procedure A000292 calculates the Tetrahedral (or pyramidal) numbers: C(n+2,3) = n(n+1)(n+2)/6. # A000292(1) = 1, A000292 (6) = 56, A000292 (9) = 165. # Procedure A000292 uses the integer partitions of n=n_in+2 into k=4 parts. # E.g. for n_in=6 we have n=8 and [6, 1, 1], [5, 2, 1], [4, 3, 1], [4, 2, 2], [3, 3, 2]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 27.10.2006 local A000292,D,T,n,i,k,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities, Term1,Term2; n := n_in + 3; k := 4; A000292 := 0; ListOfPartitions:=PartitionList(n,k); for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); Term1 := T!; Term2 := mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D); A000292 := A000292 + Term1/Term2; print(ListOfPartitions[i],Term1,Term2,Term1/Term2); od; print(n_in,A000292); end proc; # ##################################################################### # ##################################################################### PartitionList := proc (n, k) # Authors: # Herbert S. Wilf and Joanna Nordlicht, # Source: # Lecture Notes "East Side West Side,..." # University of Pennsylvania, USA, 2002. # Avalible at: http://www.cis.upenn.edu/~wilf/lecnotes.html # Berechnet die Partitionen von *** n *** # mit *** k *** Summanden. local East, West; if n < 1 or k < 1 or n < k then RETURN([]) elif n = 1 then RETURN([[1]]) else if n < 2 or k < 2 or n < k then West := [] else West := map(proc (x) options operator, arrow; [op(x), 1] end proc, PartitionList(n-1, k-1)) end if; if k <= n-k then East := map(proc(y) options operator, arrow; map(proc (x) options operator, arrow; x+1 end proc, y) end proc, PartitionList(n-k, k)) else East := [] end if; RETURN([op(West), op(East)]) end if end proc; # ##################################################################### # ##################################################################### PowersOf4 := proc(n::integer) # Procedure PowersOf4 calculates the powers of 4 = 4^n (= A000302). # a = 4^n, a(1) = 4, a(2)=16, a(5) = 1024. # Procedure PowersOf4 uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 14.10.2006 local a,D,T,i,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=partition(n); a := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); a := a+(T!/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D))*2^(n-1); od; print(n,a); end proc; A000312 := proc(n::integer) # Procedure A000312 calculates the number of labeled mappings from n points to themselves # (endofunctions): n^n. # A000312(1) = 1, A000312(6) = 46656, B(9) = 387420489. # Procedure A000312 uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 15.10.2006 local A000312,D,T,i,j,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=partition(n); A000312 := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); A000312 := A000312+(n!/mul(op(j,ASinglePartition)!,j=1..T))*(n!/(n-T)!/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D)); od; print(n,A000312); end proc; A000326 := proc(n::integer) # Procedure A000326 calculates the Pentagonal numbers: n(3n-1)/2. # A000326(1) = 1, A000326(6) = 51, A000326(9) = 117. # Procedure A000326 uses the n integer partitions of n of the form [1,n-1]. # E.g. for n = 5 we use the partition [1,4]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 10.11.2006 local A000326,m,i,j,k,ASinglePartition,ListOfPartitions; A000326 := 0; k:=2; m:=2; for i from 1 to n do ListOfPartitions:=PartitionList(m,k); ASinglePartition := ListOfPartitions[1]; #print( ListOfPartitions[1]); A000326 := A000326 + mul(op(j,ASinglePartition),j=1..k); m:=m+3; od; print(n,A000326); end proc; # ##################################################################### # ##################################################################### PartitionList := proc (n, k) # Authors: # Herbert S. Wilf and Joanna Nordlicht, # Source: # Lecture Notes "East Side West Side,..." # University of Pennsylvania, USA, 2002. # Avalible at: http://www.cis.upenn.edu/~wilf/lecnotes.html # Berechnet die Partitionen von *** n *** # mit *** k *** Summanden. local East, West; if n < 1 or k < 1 or n < k then RETURN([]) elif n = 1 then RETURN([[1]]) else if n < 2 or k < 2 or n < k then West := [] else West := map(proc (x) options operator, arrow; [op(x), 1] end proc, PartitionList(n-1, k-1)) end if; if k <= n-k then East := map(proc(y) options operator, arrow; map(proc (x) options operator, arrow; x+1 end proc, y) end proc, PartitionList(n-k, k)) else East := [] end if; RETURN([op(West), op(East)]) end if end proc; # ##################################################################### # ##################################################################### A000330 := proc(n::integer) # Procedure A000330 calculates the Square pyramidal numbers: 0^2+1^2+2^2+...+n^2 = n(n+1)(2n+1)/6. # A000330(1) = 1, A000330(6) = 91, A000330(9) = 285. # Procedure A000330 uses the integer partitions of n into k=2 parts, # e.g. for n=5 we have [4, 1] and [3, 2]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 02.11.2006 local A000330,D,i,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=PartitionList(n,2); A000330 := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); A000330 := A000330+add(op(1,op(s,ListOfDifferentPartsAndMultiplicities))^2,s=1..D); od; print(n,A000330); end proc; # ##################################################################### # ##################################################################### PartitionList := proc (n, k) # Authors: # Herbert S. Wilf and Joanna Nordlicht, # Source: # Lecture Notes "East Side West Side,..." # University of Pennsylvania, USA, 2002. # Avalible at: http://www.cis.upenn.edu/~wilf/lecnotes.html # Berechnet die Partitionen von *** n *** # mit *** k *** Summanden. local East, West; if n < 1 or k < 1 or n < k then RETURN([]) elif n = 1 then RETURN([[1]]) else if n < 2 or k < 2 or n < k then West := [] else West := map(proc (x) options operator, arrow; [op(x), 1] end proc, PartitionList(n-1, k-1)) end if; if k <= n-k then East := map(proc(y) options operator, arrow; map(proc (x) options operator, arrow; x+1 end proc, y) end proc, PartitionList(n-k, k)) else East := [] end if; RETURN([op(West), op(East)]) end if end proc; # ##################################################################### # ##################################################################### NumberOfPreferentialArrangements := proc(n::integer) # Procedure NumberOfPreferentialArrangements calculates the numbers H(n) # of preferential arrangements (= A000670). # H = preferential arrangement, H(1) = 1, H(6) = 4683, H(9) =7087261. # Procedure NumberOfPreferentialArrangements uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 14.10.2006 local H,D,T,i,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=partition(n); H := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); H := H+(n!/mul(op(j,ASinglePartition)!,j=1..T))*(T!/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D)); od; print(n,H); end proc; LAHNumbers := proc(n::integer) # Procedure LAHNumbers calculates the LAH numbers LAH(n) = (n-1)*n!/2 (= A001286) # LAH = LAH number, LAH(1) = 0, LAH(3) = 6, LAH(5) = 240. # Procedure LAHNumbers uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 13.10.2006; local LAH,D,T,i,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=partition(n); LAH := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); if T = 2 then ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); LAH := LAH+(n!/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D)); fi; od; print(n,LAH); end proc; A002627 := proc(n::integer) # Procedure A002627 calculates the sequence a(n) = n*a(n-1) + 1. # A002627(1) = , A002627(6) = 1237, A(9) = 623530. # Procedure A002627 uses the integer partitions of n with no part greater than k, # but with at least one part equal to k, # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 02.11.2006 local A002627,C,D,k,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; A002627 := 0; for k from 1 to n do ListOfPartitions:=ListIntegerPtns(n,k); ASinglePartition := ListOfPartitions[1]; #print( ListOfPartitions[1]); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); A002627 := A002627 + (n!/ mul(op(1,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D)); od; print(n,A002627); end proc; # ##################################################################### # ##################################################################### ListIntegerPtns := proc (n, k) # Authors: # Herbert S. Wilf and Joanna Nordlicht, # Source: # Lecture Notes "East Side West Side,..." # University of Pennsylvania, USA, 2002. # Avalible at: http://www.cis.upenn.edu/~wilf/lecnotes.html # Berechnet die Partitionen von *** n *** # mit mindestens einem Summanden gleich *** k *** # und keinem Summandem groesser als **** k ***. local east, west, eastop, westop; option remember; eastop := proc (y) options operator, arrow; applyop(proc (t) options operator, arrow; t+1 end proc, 1, y) end proc; westop := proc (y, j) options operator, arrow;[j, op(y)] end proc; if n <= 0 or k <= 0 or n < k then RETURN([]) elif n = 1 then RETURN([[1]]) else east := ListIntegerPtns(n-1, k-1); west:= ListIntegerPtns(n-k, k); RETURN([op(map(eastop,east)),op(map(westop, west, k))]) end if end proc; # ################################################################### # #################################################################### A005651 := proc(n::integer) # Procedure A005651 calculates the sum of the multinomial coefficients. # A005651 (1) = 1, A005651 (6) = 1602, A005651(9) = 871030. # Procedure A005651 uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 18.10.2006; local A005651,T,i,j,ASinglePartition,ListOfPartitions; ListOfPartitions:=partition(n); A005651 := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); A005651 := A005651 + n!/mul(op(j,ASinglePartition)!,j=1..T) od; print(n,A005651); end proc; BinomialCoefficients := proc(n_in::integer,k_in::integer) # Procedure BinomialCoefficient calculates the binomial coefficient C(n,k) (= A007318). # C = binomial coefficient, e.g. C(4,2) = 6, C(7,4) = 35, C(5,5) = 1. # Procedure BinomialCoefficients uses the integer partitions of n=n_in+1 into k=k_in+1 parts. # E.g. for n_in=7 and k_in=2 we have n=8 and k=3 and [6, 1, 1], [5, 2, 1], [4, 3, 1], [4, 2, 2], [3, 3, 2]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 30.10.2006 local C,D,T,i,k,n,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; n := n_in+1; k := k_in+1; ListOfPartitions:=PartitionList(n,k); C := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; #T := nops(ASinglePartition); # T = k by defniniton. ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); C := C + (k!/ mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D)); od; print(n_in,k_in,C); end proc; # ##################################################################### # ##################################################################### PartitionList := proc (n, k) # Authors: # Herbert S. Wilf and Joanna Nordlicht, # Source: # Lecture Notes "East Side West Side,..." # University of Pennsylvania, USA, 2002. # Avalible at: http://www.cis.upenn.edu/~wilf/lecnotes.html # Berechnet die Partitionen von *** n *** # mit *** k *** Summanden. local East, West; if n < 1 or k < 1 or n < k then RETURN([]) elif n = 1 then RETURN([[1]]) else if n < 2 or k < 2 or n < k then West := [] else West := map(proc (x) options operator, arrow; [op(x), 1] end proc, PartitionList(n-1, k-1)) end if; if k <= n-k then East := map(proc(y) options operator, arrow; map(proc (x) options operator, arrow; x+1 end proc, y) end proc, PartitionList(n-k, k)) else East := [] end if; RETURN([op(West), op(East)]) end if end proc; # ##################################################################### # ##################################################################### A007526 := proc(n::integer) # A007526 = The number of (nonnull) "variations" of n distinct objects. # A007526(1)=1, A007526(6)=1956, A007526(9)=986409. # sbst = a set formed from the elements of set [1,2,3,...,n]. # E.g. for n = 3 we have as possible subsets [1], [2], [3], [1,2], [1,3], [2,3], [1,2,3]. # Example: A007526(n=3)=15 because 1!+1!+1!+2!+2!+2!+3! = 15. # Maple function 'choose(n)' returns a list of all combinations of the first n integers, # i.e. all subsets as outlined above. E.g. choose(3,2) gives [[1, 2], [1, 3], [2, 3]]. # http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 14.06.2006 local a,i,k,setlist,sbst,nprts,liste,ndffrntprts; a := 0; for k from 1 to n do setlist := choose(n,k); for i from 1 to nops(setlist) do sbst := setlist[i]; nprts:= nops(sbst); a := a + nprts! od; od; print (a); end proc; A007841 := proc(n::integer) # Procedure A007841 calculates the sum (taken over all partitions of n) of the reciprocals of the products q_{t}. # q_{t} = the product of all parts of a partition. # A007841(1) = 1, A007841(6) = 2324, A007841(9) = 1674264. # Procedure A007841 uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 17.10.2006 local A007841,D,T,i,j,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=partition(n); A007841 := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); A007841 := A007841+n!/mul(op(j,ASinglePartition),j=1..T); od; print(n,A007841); end proc; Stirling1Numbers := proc(n::integer,k::integer) # Procedure Stirling1Number calculates the Stirling numbers S1(n,k) of the first kind (= A008275). # S1 = Stirling number of the first kind, S1(5,1) = 24, S1(6,3) = 225, S1(1,1) = 1. # Procedure Stirling1Numbers uses the integer partitions of n into k parts. # E.g. for n=8 and k=3 we have [6, 1, 1], [5, 2, 1], [4, 3, 1], [4, 2, 2], [3, 3, 2]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 29.10.2006 local S1,D,T,i,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=PartitionList(n,k); S1 := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := k; ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); S1 := S1+(n!/mul(op(j,ASinglePartition),j=1..T))*(1/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D)); od; print(n,k,S1); end proc; # ##################################################################### # ##################################################################### PartitionList := proc (n, k) # Authors: # Herbert S. Wilf and Joanna Nordlicht, # Source: # Lecture Notes "East Side West Side,..." # University of Pennsylvania, USA, 2002. # Avalible at: http://www.cis.upenn.edu/~wilf/lecnotes.html # Berechnet die Partitionen von *** n *** # mit *** k *** Summanden. local East, West; if n < 1 or k < 1 or n < k then RETURN([]) elif n = 1 then RETURN([[1]]) else if n < 2 or k < 2 or n < k then West := [] else West := map(proc (x) options operator, arrow; [op(x), 1] end proc, PartitionList(n-1, k-1)) end if; if k <= n-k then East := map(proc(y) options operator, arrow; map(proc (x) options operator, arrow; x+1 end proc, y) end proc, PartitionList(n-k, k)) else East := [] end if; RETURN([op(West), op(East)]) end if end proc; # ##################################################################### # ##################################################################### Stirling2Numbers := proc(n::integer,k::integer) # Procedure Stirling2Number calculates the Stirling numbers S2(n,k) of the second kind (= A008277). # S2 = Stirling number of the second kind, S2(4,2) = 7, S2(7,4) = 350, S2(5,5) = 1. # Procedure Stirling2Numbers uses the integer partitions of n into k parts. # E.g. for n=8 and k=3 we have [6, 1, 1], [5, 2, 1], [4, 3, 1], [4, 2, 2], [3, 3, 2]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 29.10.2006 local S2,D,T,i,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=PartitionList(n,k); S2 := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := k; ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); S2 := S2+(n!/mul(op(j,ASinglePartition)!,j=1..T))*(1/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D)); od; print(n,k,S2); end proc; EulerNumbers := proc(n::integer,k_in::integer) # Procedure EulerNumber calculates the Euler numbers E(n,k) (= A008292). # E = Euler number, E(1,1) = 1, E(5,3) = 26, E(6,2) = 302. # Procedure EulerNumber uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 18.10.2006 local i,j,k,s,T,D,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities,C,E; k := k_in - 1; ListOfPartitions:=partition(n+1+1); E := 0; for j from 0 to k do C := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); if T - 1 = j then C := C + (T!/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D)); fi; od; E := E + (-1)^j * C * (k - j + 1)^n; od; print(n,k,E); end proc; A014968 := proc(n::integer) # Procedure A014968 calculates the expansion of (1/theta_4 - 1)/2. # A014968 = the expansion of (1/theta_4 - 1)/2, A014968(1) = 1, A014968(6) = 20, A014968(9) = 77. # Procedure A014968 uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 14.10.2006 local A014968,D,i,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=partition(n); A014968 := 0; ListOfPartitions:=partition(n); for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; D:=nops(convert(ASinglePartition,multiset)); for s from 1 to D do A014968 := A014968 + binomial(D-1,s-1); od; od; print("n, A014968(n): ",n, A014968); end proc; A050351 := proc(n::integer) # Procedure A050351 calculates the number of lists of lists of sets. # A050351 = number of lists of lists of sets, A050351(1) = 1, A050351(6) = 66605, A050351(9) = 503589781. # Procedure A050351 uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 14.10.2006 local A050351,D,T,i,j,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=partition(n); A050351 := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition ); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); A050351 := A050351+(n!/mul(op(j,ASinglePartition)!,j=1..T))*(T!/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D))*2^(T-1); od; print(n,A050351); end proc; A082579 := proc(n::integer) # Procedure A082579 calculates the sum (taken over all partitions of n) of the quotients q_{t/m!}. # q_{t/m!} = the product of all parts of a partition divided by the product of the factorials of the multiplicities of these parts. # A082579(1) = 1, A082579(6) = 24781, A082579(9) = 67308841. # Procedure A082579 uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 17.10.2006 local A082579,D,T,i,j,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=partition(n); A082579 := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); A082579 := A082579+n!*mul(op(j,ASinglePartition),j=1..T)/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D); od; print(n,A082579); end proc; A093694 := proc(n::integer) # Procedure A093694 calculates the number of one-element transitions # from the partitions of n to the partitions of n+1 for labeled parts. # A093694(1)=2, A093694(6)=46, A093694(9)=158. # Procedure A093694 uses the integer partitions of n. # E.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 18.10.2006 local A093694,i,T,ASinglePartition,ListOfPartitions; ListOfPartitions:=partition(n); A093694 := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; T := nops(ASinglePartition); A093694 := A093694 + T + 1; od; print(n,A093694); end proc; A098407 := proc(n::integer) # Procedure A098407 calculates the number of different hierarchical orderings # that can be formed from n unlabeled elements with no repetition of subhierarchies. # A098407(1) = 1, A098407(6) = 78, A098407(9) = 1028. # Procedure A098407 uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 17.10.2006 local A098407,i,s,D,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities, APart,MultiplicityOfAPart,Product; ListOfPartitions:=partition(n); A098407 := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); Product := 1; for s from 1 to D do APart := op(1,op(s,ListOfDifferentPartsAndMultiplicities)); MultiplicityOfAPart := op(2,op(s,ListOfDifferentPartsAndMultiplicities)); Product := Product * binomial(2^(APart-1),MultiplicityOfAPart); od; A098407 := A098407 + Product; od; print(n,A098407); end proc; A104533 := proc(n::integer) # Procedure A104533 calculates the number of hierarchical orderings for n labeled elements # (see A075729) but there are two kinds A and B of elements. # A104533(1) = 2, A104533(6) = 259264, A104533(9) = 2353435136. # Procedure A104533 uses the integer partitions of n, # e.g. partition(5) gives [1,1,1,1,1], [1,1,1,2], [1,1,3], [1,4], [1,2,2], [23], [5]. # ASinglePartition = ListOfPartitions[i] = the i-th integer partition of n. # T = number of parts of the i-th partition ASinglePartition. # D = number of different parts of the i-th partition ASinglePartition. # t(i,j) = op(j,ASinglePartition) = the j-th part of the i-th partition ASinglePartition. # m(i,s) = op(2,op(s,ListOfDifferentPartsAndMultiplicities)) = multipliticity of the s-th different part d(i,j) # of the i-th partition ASinglePartition. # In [1,1,1,3,4] there are T=5 parts and D=3 different parts, # namely d(1)=1, d(2)=3, d(3)=4. The part d(1) has a multiplicity of 3. # thomas.wieder@t-online.de http://www.thomas-wieder.privat.t-online.de/default.html # Letzte Aenderung: 17.10.2006 local A104533,D,i,s,ASinglePartition,ListOfPartitions,ListOfDifferentPartsAndMultiplicities; ListOfPartitions:=partition(n); A104533 := 0; for i from 1 to nops(ListOfPartitions) do ASinglePartition := ListOfPartitions[i]; ListOfDifferentPartsAndMultiplicities := convert(ASinglePartition,multiset); D := nops(ListOfDifferentPartsAndMultiplicities); A104533 := A104533+(n!/mul(op(2,op(s,ListOfDifferentPartsAndMultiplicities))!,s=1..D))*2^n; od; print(n,A104533); end proc; ####################################################################### ### END OF PART C: ALL FORMULAS AS MAPLE PROGRAMS. #######################################################################