#Write a Maple procedure CS(n) that inputs a #positive integer n and outputs the number mu(n) #defined in sequence A094004. #This will return true if L1 is a final #segment of L2. IsFinalSegment:=proc(L1,L2): if(nops(L1)>nops(L2)) then return FAIL: fi: return(evalb(L1=L2[nops(L2)-nops(L1)+1..nops(L2)])): end: CS:=proc(n) local L,i,j,q,max,y,yrep,len,k,kmax,cont: max:=1: #Now we just do the curling. #For now we will be really dumb about it. for i from 0 to 2^n-1 do L:=ListTools:-Reverse(Bits:-Split(i,bits=n)): for q from 1 to n do L[q]:=L[q]+2: od: cont:=true: while(cont=true) do kmax:=1: #Find how to write L as xy^k, k maximal. for j from 1 to nops(L)/2 do y:=L[(nops(L)-j+1)..nops(L)]: k:=1: yrep:=y: while (IsFinalSegment(yrep,L)=true) do k:=k+1: yrep:=[op(yrep),op(y)]: #print(yrep,k): #DEBUG(): od: #At this point we know xy^(k-1) is the way to write L[i] #with that particular y. if ((k-1)>kmax) then kmax:=k-1: fi: od: #Now you know the maximal k among all possible ys. if kmax>=2 then L:=[op(L),kmax]: #print(L,`length+`): else #print(L): cont:=false: fi: od: #print(L): if (nops(L)>max) then max:=nops(L): fi: od: return max: end: