OFFSET
1,1
COMMENTS
Original title: Rearrangement of natural numbers such that the n-th partial sum is divisible by the n-th prime.
The numbers 3, 9, 13, ... do not appear in the first 1655 terms of this sequence. Is this truly a permutation of the natural numbers? - Derek Orr, Jun 16 2015
a(100959)=13. - Alois P. Heinz, Jun 17 2015
The numbers 3, 9, 16, 18, 19, ... do not appear in the first 80 million terms of this sequence - Carl R. White, Mar 07 2024
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..20000
Carl R. White, C source to generate 80 million terms
MAPLE
b:= proc() false end:
s:= proc(n) option remember; a(n)+s(n-1) end: s(0):=0:
a:= proc(n) option remember; local k, p; p:= ithprime(n);
for k from p*(iquo(s(n-1), p)+1)-s(n-1)
while b(k) by p do od; b(k):= true; k
end:
seq(a(n), n=1..100); # Alois P. Heinz, Jun 17 2015
MATHEMATICA
f[lst_] := Block[{k = 1, p = Prime[1 + Length@ lst], s = Total@ lst}, While[Mod[s + k, p] != 0 || MemberQ[lst, k], k++]; Append[lst, k]]; Nest[f, {}, 64] (* Robert G. Wilson v, Jun 17 2015 *)
PROG
(PARI) v=[2]; n=1; while(n<10^3, s=(n+vecsum(v))%prime(#v+1); if(!(s||vecsearch(vecsort(v), n)), v=concat(v, n); n=0); n++); v \\ Derek Orr, Jun 16 2015
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Amarnath Murthy, Sep 13 2002
EXTENSIONS
More terms from David Wasserman, Jan 16 2005
STATUS
approved