#Python 2, <s>64</s> 63 bytes Anonymous function with arguments `n` and `k`, returns the list to output. <!-- language: lang-py --> lambda n,k:[[i,'Shaggy'][i%k<1or`k`in`i`]for i in range(1,n+1)] Alternatively, a function which prints to `STDOUT` for the same bytecount: <!-- language: lang-py --> def f(n,k,i=1):exec"print[i,'Shaggy'][i%k<1or`k`in`i`];i+=1;"*n