function [M] = A091976(nmax)
% Returns the first "nmax" terms of A091976.
M=[(1:nmax)',zeros(nmax,1)];
for n = 1:nmax
    k=1;
    for a=1:floor((n-1)/2) %lengths of permutations
        if n-(k)*a-a>0 %no need to check permutations lengths which go beyond current leader for k
            c=1;
            p=sort(M(n-a:n-1,2));
            while n-c*a-a>0 && isequal(p,sort(M(n-c*a-a:n-1-c*a,2)))
                c=c+1;
            end
            if c>k
                k=c;
            end
        end
    end
    M(n,2)=k;
end
end