

A019444


a_1, a_2, ..., is a permutation of the positive integers such that the average of each initial segment is an integer, using the greedy algorithm to define a_n.


8



1, 3, 2, 6, 8, 4, 11, 5, 14, 16, 7, 19, 21, 9, 24, 10, 27, 29, 12, 32, 13, 35, 37, 15, 40, 42, 17, 45, 18, 48, 50, 20, 53, 55, 22, 58, 23, 61, 63, 25, 66, 26, 69, 71, 28, 74, 76, 30, 79, 31, 82, 84, 33, 87, 34, 90, 92, 36, 95, 97, 38, 100, 39, 103, 105, 41, 108, 110, 43, 113
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,2


COMMENTS

Selfinverse when considered as a permutation or function, i.e. a(a(n)) = n.  Howard A. Landman, Sep 25 2001
That each initial segment has an integer average is trivially equivalent to the sum of the first n elements always being divisible by n.  Franklin T. AdamsWatters, Jul 07 2014
Also, a lexicographically minimal sequence of distinct positive integers such that all values of a(n)n are also distinct.  Ivan Neretin, Apr 18 2015


LINKS

Franklin T. AdamsWatters, Table of n, a(n) for n=1..10000
A. Shapovalov, Problem M1517 (in Russian), Kvant 5 (1995), 2021. (English translation appeared in Quantum, Sept/October 1996)
The Math Forum, Problem of the Week 818
B. J. Venkatachala, A curious bijection on natural numbers, JIS 12 (2009) 09.8.1
Index entries for sequences that are permutations of the natural numbers


FORMULA

a(n) = A002251(n1) + 1. (Corrected by M. F. Hasler, Sep 17 2014)
Let s(n) = sum(k=1,n,a(k))/n = A019446(n). Then if s(n1) does not occur in a(1),...,a(n1), a(n) = s(n) = s(n1); otherwise, a(n) = s(n1) + n and s(n) = s(n1) + 1. [From Franklin T. AdamsWatters, May 20 2010]


MATHEMATICA

a[1]=1; a[n_] := a[n]=Module[{s, v}, s=a/@Range[n1]; For[v=Mod[ Plus@@s, n], v<1MemberQ[s, v], v+=n, Null]; v]
lst = {1}; f[s_List] := Block[{k = 1, len = 1 + Length@ lst, t = Plus @@ lst}, While[ MemberQ[s, k]  Mod[k + t, len] != 0, k++ ]; AppendTo[lst, k]]; Nest[f, lst, 69] (* Robert G. Wilson v, May 17 2010 *)
Fold[Append[#1, #2 Ceiling[#2/GoldenRatio]  Total[#1]] &, {1}, Range[2, 70]] (* Birkas Gyorgy, May 25 2012 *)


PROG

(PARI) al(n)=local(v, s, fnd); v=vector(n); v[1]=s=1; for(k=2, n, fnd=0; for(i=1, k1, if(v[i]==s, fnd=1; break)); v[k]=if(fnd, s+k, s); s+=fnd); v \\ Franklin T. AdamsWatters, May 20 2010


CROSSREFS

Cf. A019445, A019446, A243700.
Sequence in context: A209171 A160855 A120232 * A195412 A069773 A122321
Adjacent sequences: A019441 A019442 A019443 * A019445 A019446 A019447


KEYWORD

nonn,nice


AUTHOR

R. K. Guy and Tom Halverson (halverson(AT)macalester.edu)


STATUS

approved



