#OK to post homework #George Spahn, 4-10-2022, Assignment 20 #1 #ConjLP(R) #Inputs a finite set of positive integers R, and outputs the pair # [M,C] # where M is a positive integer ≥ 2 and C is a subset of {0,1,...,M-1} # such that PR(n,R)[1]=0 if and only if n mod M belongs to C ConjLP := proc(R) local M, Mokay, C,c,c0,c1,n: for M from 2 do Mokay := true: C:={}: for c from 0 to M-1 do c0 := true: c1 := true: for n from c to 100 by M do if PR(n,R)[1]=0 then C := C union {c}: c1 := false: if c0 = false then Mokay := false: break: fi: else c0 := false: if c1 = false then Mokay := false: break: fi: fi: od: if not(Mokay) then break: fi: od: if Mokay then RETURN([M,C]) fi: od: end: #PR(n,R): Inputs a pos. integer n and a set of POSITIVE integers R #outputs 0,{} or 1,S where 0 means losing and S is the set of winning moves PR:=proc(n,R) local i,S: option remember: S:={}: for i in R do if i<=n and PR(n-i,R)[1]=0 then S:=S union {i}: fi: od: if S={} then 0,S: else 1,S: fi: end: