

A330288


Start with the list of numbers from 1 to n. As long as the list has odd and even elements, append to the list the sum of the smallest odd and smallest even elements, taken with multiplicity, and delete these terms from the list. a(n) is the largest element in the final list.


1



1, 3, 3, 10, 15, 21, 17, 21, 19, 29, 29, 49, 47, 49, 91, 75, 73, 75, 73, 75, 73, 75, 73, 75, 73, 75, 123, 121, 135, 135, 131, 135, 131, 131, 163, 157, 153, 157, 187, 193, 181, 193, 215, 223, 213, 213, 277, 275, 243, 243, 321, 299, 289, 291, 261, 265, 261, 265, 261
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,2


COMMENTS

Conjecture: a(4)=10 is the only even term.  Jon E. Schoenfield, Dec 28 2019


LINKS

Table of n, a(n) for n=1..59.


EXAMPLE

To find a(8), create the list {1, 2, 3, 4, 5, 6, 7, 8}. Remove from this list the least odd element (1) and the least even element (2) and insert their sum 1 + 2 = 3, to get the new list {3, 3, 4, 5, 6, 7, 8}. The least odd element (3) is present twice, the least even element (4) once. Remove all these from the list and insert their sum, 3 + 3 + 4 = 10, to get the new list {5, 6, 7, 8, 10}. Now, the least odd element is 5 and the least even element is 6. Add them to get the list {7, 8, 10, 11}. Now, replace 7 and 8 with their sum and the list becomes {10, 11, 15}. Replace 10 and 11 with their sum and the list becomes {15, 21}. There is no even element left, so a(8) = 21, the largest element in the list.


MATHEMATICA

Array[FixedPoint[If[AnyTrue[{#2, #3}, ! IntegerQ@ # &], {Max@ #1}, Sort@ {Delete[#1, #3], #2} & @@ {#1, #2 Count[#1, #2] + #3 Count[#1, #3], Position[#1, k_ /; ! FreeQ[{#2, #3}, k]]}] & @@ {#, SelectFirst[#, OddQ], SelectFirst[#, EvenQ]} &, Range@ #][[1]] &, 59] (* Michael De Vlieger, Dec 14 2019 *)


PROG

(PARI) apply( A330288(n)={ my( even=[1..n\2]*2, odd=[ 2*k1  k<[1..n\/2]],
keep(S)=[t  t<S, t>S[1]], s); while( even && odd,
s = even[1]*(#even  #even=keep(even)) + odd[1]*(#odd  #odd=keep(odd));
if( s%2, odd=vecsort(concat(odd, s)), even=vecsort(concat(even, s)) ));
if( odd, vecmax(odd), vecmax(even))}, [1..99]) \\ M. F. Hasler, Dec 08 2019


CROSSREFS

Sequence in context: A277963 A193965 A301279 * A262923 A319882 A225860
Adjacent sequences: A330285 A330286 A330287 * A330289 A330290 A330291


KEYWORD

nonn


AUTHOR

Ali Sada, Dec 09 2019


EXTENSIONS

Definition and terms corrected by M. F. Hasler


STATUS

approved



