login
a(1) = 1, a(n) = the smallest composite multiple of n such that every partial sum is prime.
2

%I #12 Sep 26 2015 17:24:07

%S 1,4,6,8,10,12,42,24,72,20,132,36,52,14,30,16,68,54,76,80,126,88,92,

%T 24,100,26,108,112,116,30,310,128,66,204,70,36,74,76,78,120,902,84,

%U 430,44,360,460,188,240,294,100,204,104,106,54,110,280,342,116,708,60,244,62

%N a(1) = 1, a(n) = the smallest composite multiple of n such that every partial sum is prime.

%H Charles R Greathouse IV, <a href="/A073669/b073669.txt">Table of n, a(n) for n = 1..10000</a>

%p a[1] := 1:su := 1:for n from 2 to 112 do i := 1: if(isprime(n)) then i := i+1:fi:while(not isprime(i*n+su)) do i := i+1:od:a[n] := i*n:su := su+a[n]:od:seq(a[j],j=1..112);

%t a[1]=s[1]=1; s[n_] := s[n]=s[n-1]+a[n]; a[n_] := a[n]=For[i=1, True, i++, If[ !PrimeQ[i*n]&&PrimeQ[s[n-1]+i*n], Return[i*n]]]

%o (PARI) first(L)=my(v=vector(L),s,k); s=v[1]=1; for(n=2,#v, k=n; while(isprime(k) || !isprime(s+k), k+=n); s+=k; v[n]=k); v \\ _Charles R Greathouse IV_, Apr 24 2015

%K nonn

%O 1,2

%A _Amarnath Murthy_, Aug 11 2002

%E Corrected and extended by _Sascha Kurz_, Jan 30 2003