OFFSET
1,2
COMMENTS
A nondecreasing sequence a_1, ..., a_n is called balanced if the n-1 quantities D(a_1,...,a_k)+D(a_(k+1),...,a_n) (1<=k<=n-1) are all equal, where D(a_1,...,a_k) is the sum of the absolute deviations of the a's from their median. Up to affine equivalence, there's a unique balanced sequence of any given length.
n is in the sequence iff n=1, 2, or 4, or n is prime and the multiplicative group of integers mod n is generated by -1 and 2.
1, 2, 4, and primes p such that either +2 or -2 (or both) are primitive roots mod p. - Joerg Arndt, Jun 03 2012
LINKS
Fred Galvin, Problem 10430, Amer. Math. Monthly, 102 (1995), 71.
Fred Galvin, John Isbell and Robin J. Chapman, Problem 10430 solution, Amer. Math. Monthly, 104 (1997), 671-672.
EXAMPLE
n=5 is in the sequence, since 0,2,3,4,6 is balanced. n=6 is not because every balanced sequence of length 6 is affinely equivalent to 0,1,2,2,3,4.
MATHEMATICA
o2[n_] := MultiplicativeOrder[2, n]; For[n=1, True, n++, If[Mod[4, n]==0||(PrimeQ[n]&&(o2[n]==n-1|| (o2[n]==(n-1)/2&&Mod[n, 4]==3))), Print[n]]]
PROG
(PARI) is(n)=n<6 || (isprime(n) && (znorder(Mod(2, n))==n-1 || znorder(Mod(-2, n))==n-1)) \\ Charles R Greathouse IV, Nov 21 2014
CROSSREFS
KEYWORD
nonn,nice
AUTHOR
EXTENSIONS
More terms and additional comments from Dean Hickerson, Sep 20 2001
STATUS
approved