OFFSET
1,1
COMMENTS
LINKS
Seppo Mustonen, On integer sequences with mutual k-residues
Seppo Mustonen, On integer sequences with mutual k-residues [Local copy]
EXAMPLE
The fourth term is 14 since mod(9,3)=0, mod(10,3)=1, mod(11,5)=1,
mod(12,3)=0, mod(13,3)=1 but mod(14,3)=2, mod(14,5)=4, mod(14,8)=6.
MAPLE
res_seq:=proc(a::array(1, nonnegint), k, n::nonnegint) local i, j, m, f; a[1]:=k+1; for i from 2 to n do m:=a[i-1]+1; f:=1; while f=1 do j:=1; while j<i and irem(m, a[j])>=k do j:=j+1; od; if j=i then a[i]:=m; f:=0; else m:=m+1; fi; od; od; end; a:=array(1..57, []); res_seq(a, 2, 57); print(a);
MATHEMATICA
seq[k_, n_] := Module[{a, i, j, m, f}, a = Table[0, {n}]; a[[1]] = k+1; For[i = 2, i <= n, i++, m = a[[i-1]]+1; f = 1; While[f == 1, j = 1; While[j < i && Mod[m, a[[j]]] >= k, j = j+1]; If[j == i, a[[i]] = m; f = 0, m = m+1]]]; a];
seq[2, 57] (* Jean-François Alcover, Oct 05 2022, after Maple code *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Seppo Mustonen, Aug 18 2005
STATUS
approved