#HomeWork#12 #Please do not post homework #Abrar Almahmeed, March 7 #Question 1: A41c1:=proc(n) option remember: local j,s: if n<0 then RETURN(0): fi: if n=0 then RETURN(1): fi: s:=0: for j from 1 while (3*j^2-j)/2 <= n do s:=s+(-1)^(j-1)*A41c1(n-(3*j^2-j)/2): if (3*j^2+j)/2 <= n then s:=s+(-1)^(j-1)*A41c1(n-(3*j^2+j)/2): fi: od: s: end: A41c:=proc(N) local n: [seq(A41c1(n),n=1..N)]: end: time(A41c(1000)); 0.078 time(A41ok(1000)); 4.046 #Question 2: # phi: implements the bijection described in the paper # L = partition [lambda1, lambda2, ..., lambdat] # j = the index in a(j)=(3*j^2+j)/2 phi:=proc(L, j) local t,i: t := nops(L): if t+3*j >= L[1] then return [t + 3*j-1, seq(L[i]-1,i=1..t)]: else return [seq(L[i]+1,i=2..t),1$(L[1]-3*j-1)]; fi: end: ##check## phi([5,5,4,3,2],1); [7, 4, 4, 3, 2, 1] #Question 3: OddToDis:=proc(p) local i,a,T: T:=[]: for i from 1 to nops(p) do a:=(p[i]-1)/2: T:=[op(T), a+1]: od: return sort(T,`>`): end: DisToOdd:=proc(n) local i,a,T: T:=[]: for i from 1 to nops(n) do a:=n[i]-1: T:=[op(T),2*a+1]: od: return sort(T,`>`): end: ##check## OddToDis([5,3,1]); [3, 2, 1] DisToOdd(%); [5, 3, 1]