%I #25 Mar 07 2024 07:31:48
%S 2,1,7,4,8,17,12,6,35,24,39,30,20,10,67,36,95,14,42,28,87,48,32,137,
%T 72,238,22,44,131,161,55,179,78,26,130,177,84,247,60,90,269,213,170,
%U 34,68,233,5,204,295,265,76,114,38,190,371,120,389,313,132,88,327,230,15,399
%N a(n) is the smallest number not already in the sequence such that Sum_{k=1..n} a(k) is divisible by prime(n).
%C Original title: Rearrangement of natural numbers such that the n-th partial sum is divisible by the n-th prime.
%C 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
%C a(100959)=13. - _Alois P. Heinz_, Jun 17 2015
%C 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
%H Alois P. Heinz, <a href="/A075085/b075085.txt">Table of n, a(n) for n = 1..20000</a>
%H Carl R. White, <a href="https://pastebin.com/C718kGA0">C source to generate 80 million terms</a>
%p b:= proc() false end:
%p s:= proc(n) option remember; a(n)+s(n-1) end: s(0):=0:
%p a:= proc(n) option remember; local k, p; p:= ithprime(n);
%p for k from p*(iquo(s(n-1), p)+1)-s(n-1)
%p while b(k) by p do od; b(k):= true; k
%p end:
%p seq(a(n), n=1..100); # _Alois P. Heinz_, Jun 17 2015
%t 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 *)
%o (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
%K nonn,look
%O 1,1
%A _Amarnath Murthy_, Sep 13 2002
%E More terms from _David Wasserman_, Jan 16 2005
|