login
A380187
Smallest integer not yet present in the sequence such that the sum of the first a(n) terms of the sequence is odd for n odd and even for n even.
1
1, 3, 4, 5, 7, 2, 9, 6, 8, 11, 12, 13, 15, 10, 17, 14, 16, 19, 20, 21, 23, 18, 25, 22, 24, 27, 28, 29, 31, 26, 33, 30, 32, 35, 36, 37, 39, 34, 41, 38, 40, 43, 44, 45, 47, 42, 49, 46, 48, 51, 52, 53, 55, 50, 57, 54, 56, 59, 60, 61, 63, 58, 65, 62, 64, 67, 68, 69
OFFSET
1,2
COMMENTS
A permutation of the natural numbers.
For n>1, a(n+1)-a(n) is periodic with a period of 8 (1, 1, 2, -5, 7, -3, 2, 3), like a(n)-n (1,1,1,2,-4,2,-2,-1).
FORMULA
a(n) = a(n-1) + a(n-8) - a(n-9), for n > 10.
G.f. : (x + 2 x^2 + x^3 + x^4 + 2 x^5 - 5 x^6 + 7 x^7 - 3 x^8 + x^9 + x^10) / (1 - x - x^8 + x^9). - Mike Sheppard, Feb 20 2025
EXAMPLE
For n = 1 we have the sum a(1) = 1, odd;
For n = 2 we cannot set a(2) = 2 because the sum of the first 2 terms would be 1 + 2 = 3, odd, but n is even.
So we try a(2) = 3.
Now we set a(3) = 4. Since a(2) = 3, we have 1 + 3 + 4 = 8, an even number, which fits the pattern.
Next we set a(4) = 5. Since a(3) = 4, we have 1 + 3 + 4 + 5 = 13, an odd number, which fits the pattern, etc.
MAPLE
P:=proc(q) local a, b; a:=[1]; b:=[-1, 1, 1, 1, 2, -4, 2, -2];
for n from 2 to q do a:=[op(a), n+b[nops(a)mod 8+1]]; od; op(a); end: P(68);
MATHEMATICA
LinearRecurrence[{1, 0, 0, 0, 0, 0, 0, 1, -1}, {1, 3, 4, 5, 7, 2, 9, 6, 8, 11}, 100] (* Paolo Xausa, Feb 03 2025 *)
CROSSREFS
Sequence in context: A154665 A056190 A202702 * A049465 A196122 A247140
KEYWORD
nonn,easy,changed
AUTHOR
Paolo P. Lava, Jan 15 2025
STATUS
approved