#HomeWork#11 #Please do not post homework #Abrar Almahmeed, March 1 #Question 1: CountNuCompsClever:= proc(a,b,A,B,N) local f,x,i: f:=GenCompsGF(a,b,A,B,x): [seq(coeff( taylor(f,x=0,N+3),x,i),i=0..N)]: end: ##Check## CountNuCompsClever(3,4,{1,2},{0,3},15); [1, 0, 0, 1, 4, 7, 10, 18, 34, 62, 114, 211, 390, 717, 1316, 2420] CountNuCompsClever(2,3,{1},{2},15); [0, 0, 1, 0, 2, 1, 3, 5, 5, 15, 13, 36, 42, 81, 128, 192] #Question 2: CountNuCompsStupid1:= proc(a,b,A,B,n) local C,L,i,check,S: if n=0 then if member(0 mod b,B) then return 1: else return 0: fi: fi: C:= Comps(n): S:= {}: for L in C do if member(nops(L) mod b, B) then check:= true: for i from 1 to nops(L) do if not member(((L[i]-1) mod a)+1, A) then check:= false: break: fi: od: if check then S := S union {L}: fi: fi: od: nops(S): end: CountNuCompsStupid:= proc(a,b,A,B,N) local n: [seq(CountNuCompsStupid1(a,b,A,B,n),n=0..N)]: end: ##Check## CountNuCompsStupid(3,4,{1,2},{0,3},15); [1, 0, 0, 1, 4, 7, 10, 18, 34, 62, 114, 211, 390, 717, 1316, 2420] CountNuCompsStupid(2,3,{1},{2},15); [0, 0, 1, 0, 2, 1, 3, 5, 5, 15, 13, 36, 42, 81, 128, 192]