OFFSET
1,2
COMMENTS
The lexicographically earliest possibility satisfying the requirement is to be considered. This practically means that the k-th group consists of the k-1 smallest numbers not yet used, followed the next smallest unused number which completes their sum to a multiple of k. - M. F. Hasler, May 07 2010
Original definition (The given example seems wrong from "23" on. [Z. Seidov & MFH]): Rearrange the natural numbers in groups so that the n-th group contains n terms and the sum is a multiple of n: (1), (2, 4), (3, 5, 7), (6, 8, 9, 13), (10, 11, 12, 14, 23), (15, 16, 17, 18, 19, 29), (20, 21, 22, 24, 25, 26, 30), (27, 28, 31, 32, 33, 34, 35, 36), ... Sequence gives sum of the terms/ n for the n-th group (the average of the group).
In the k-th group the first (k-1) terms are partly all the numbers not included earlier followed by numbers in increasing order and then the k-th term is chosen so that the sum is a multiple of k.
EXAMPLE
From M. F. Hasler, May 07 2010: (Start)
Below the groups are given inside /*...*/, followed by the average a(n):
/*[1]*/ 1,
/*[2, 4]*/ 3,
/*[3, 5, 7]*/ 5,
/*[6, 8, 9, 13]*/ 9,
/*[10, 11, 12, 14, 18]*/ 13,
/*[15, 16, 17, 19, 20, 21]*/ 18,
/*[22,23, 24, 25, 26, 27, 28]*/ 25,
/*[29, 30, 31, 32, 33, 34, 35, 40]*/ 33,
/*[36, 37, 38, 39, 41, 42, 43, 44, 49]*/ 41,
/*[45, 46, 47, 48, 50, 51, 52, 53, 54, 64]*/ 51,
/*[55, 56, 57, 58, 59, 60, 61, 62, 63, 65, 75]*/ 61,
/*[66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 77, 81]*/ 72, ... (End)
PROG
(PARI) {v=vector(10000); print1(v[1]=1); for(n=2, 80, s=0; i=1; for(k=1, n-1, while(v[i], i++); s+=i; v[i]=1); i=ceil(s/n)*n-s; while(! i||v[i], i+=n); s+=i; v[i]=1; print1(", "s/n))}
(PARI)
/* Removing the code involving "show" considerably speeds up the computation */
A074133(n, show=0 /* 1:print terms 1..n, 2:print all groups */)={
my(t, u=0, lu=1 /* least unused */); for(k=1, n, my(v=[]); s=sum( i=1, k-1,
t=lu; while(bittest(u, t), t++); show>1 & v=concat(v, t); u+=1<<t;
t==lu & while( bittest(u, lu++), ); t); forstep(n=max(lu-1, s)\k*k+k, 1e9, k,
bittest(u, n-s) & next; u+=1<<(n-s); show>1 & print1("/*"concat(v, n-s)"*/ ");
t=n/k; show & print1(t, ", "); break)); t} \\ M. F. Hasler, May 07 2010
CROSSREFS
KEYWORD
nonn
AUTHOR
Amarnath Murthy, Aug 27 2002
EXTENSIONS
Corrected and extended by Ralf Stephan, Mar 26 2003
Edited by M. F. Hasler, May 09 2010
STATUS
approved