Here's a simple-minded solution in C. (I wonder how fast a
straightforward translation of this to J with control words would
run.)
$ cat gijl.c
// OEIS A090822 Gijswijt's sequence
void
gij(int nm, char *a) {
for(int n = 0; n < nm; n++) {
int r = 1;
for (int l = 1; l <= n/2; l++) {
int s = 0;
int q = 0;
while (!q) {
s++;
if (l * (1+s) <= n)
for (int u = 1; !q && u <= l; u++)
q = a[n - l * (s - 1) - u] !=
a[n - l * s - u];
else
q = 1;
}
if (r < s)
r = s;
}
a[n] = r;
}
}
$ gcc -shared -fpic -std=gnu99 -Wall -O -o gijl.so gijl.c
$ jconsole
gij=: a.i. 2{:: './gijl.so gij n i *c' 15!:0 ];$&'x'
gij 30
1 1 2 1 1 2 2 2 3 1 1 2 1 1 2 2 2 3 2 1 1 2 1 1 2 2 2 3 1 1
Ambrus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm