login
A333590
a(n) = a(n-1) if half of the previous term pairs are inverted. a(n) = a(n-1) + 1 if more than half of the previous term pairs are inverted. a(n) = a(n-1) - 1 if fewer than half of the previous term pairs are inverted. a(1) = 0.
1
0, 0, -1, 0, -1, -1, 0, -1, -2, -1, 0, -1, -2, -1, -2, -1, 0, -1, -2, -3, -2, -1, 0, -1, -2, -3, -2, -1, 0, -1, -2, -3, -2, -1, 0, -1, -2, -3, -4, -3, -2, -1, 0, 1, 0, -1, -2, -3, -4, -5, -4, -3, -2, -1, 0, 1, 0, -1, -2, -3, -4, -3, -2, -1, 0, -1, -2, -3, -4, -3, -2, -1
OFFSET
1,9
COMMENTS
An inversion occurs when some term is greater than some later term.
A sequence of length n can have at most n * (n - 1) / 2 inversions.
EXAMPLE
There are zero inversions in the first two terms of this sequence. The maximum possible number of inversions in a sequence of length 2 is 1. 0 is less than half of 1, so the third term is 0 - 1 or -1.
There are two inversions in the first 3 terms of this sequence. The maximum possible number of inversions in a sequence of length 3 is 3. 2 is more than half of 3, so the fourth term is -1 + 1 or 0.
PROG
(C) // See Links section.
(PARI) { my(v=0, f=vector(2*M=100), s=0, inv=0); for (n=1, 72, f[M+v]++; inv+=s; print1 (v", "); if (2*inv<t=n*(n-1)/2, s+=f[M+v]; v--, 2*inv>t, v++; s-=f[M+v])) } \\ Rémy Sigrist, Mar 28 2020
CROSSREFS
Cf. A323186.
Sequence in context: A360711 A284620 A038698 * A263233 A300623 A087991
KEYWORD
sign
AUTHOR
Samuel B. Reid, Mar 27 2020
STATUS
approved