[seqfan] Re: Sum of the a(n) first digits of S is a prime -- an illusion?

Maximilian Hasler maximilian.hasler at gmail.com
Mon Aug 30 21:37:48 CEST 2010


On Mon, Aug 30, 2010 at 1:21 PM, Eric Angelini <Eric.Angelini at kntv.be> wrote:
>
> « Smallest integer not yet present in S such that the sum of the a(n) first digits of S is a prime »:
>
> I get by hand:
>
> S = 2,1,4,6,3,7,8,60,9,11,14,17,61,16,22,25,30,26,28,34,49,37,200,36,38,39,42,59,51,54,56,61,69,201,...

not bad... but I get something different for the last 3 of your terms,
when I compute some more :
The following 86 terms satisfy the criteria ("so far"):

[2, 1, 4, 6, 3, 7, 8, 60, 9, 11, 14, 17, 61, 16, 22, 25, 30, 26, 28,
34, 49, 37, 200, 36, 38, 39, 42, 59, 51, 54, 56, 62, 71, 600, 65, 70,
66, 75, 201, 72, 67, 68, 82, 100, 83, 84, 91, 93, 300, 94, 95, 301,
98, 101, 103, 110, 116, 120, 302, 121, 130, 132, 202, 133, 141, 500,
142, 143, 148, 150, 154, 155, 165, 303, 166, 174, 203, 175, 183, 204,
184, 192, 196, 290, 208, 800, ...]

But maybe one of the terms is wrong, since my code takes "infinitely"
long to extend this to 87 terms...

The above terms are computed using ' try2complete(86) ',
the code is given below.

Best regards,
Maximilian

isgood( a )={ /* #a == #vecsort(a,,8) | return;
-- for efficiency, this check for duplicate terms is omitted */
my( d = Vecsmall( concat( vector( #a, i, Str(a[i])) )), s = 0);
/* using ASCII codes (Vecsmall) is 2x faster than eval(Vec(...)) */
d=vector( #d, i, s+= d[i]-48 );
for( i=1,#a, a[i] > #d | isprime( d[ a[i] ] ) | return ); 1}

{try2complete( N=10 /* # of required terms */, a=[],
L=1000 /* search limit */)=
#a < N | return(a); /* required length is already reached */
my( old = Set(a) ); a = concat(a,0);
while( a[#a] ++ < L,
 setsearch( old, a[#a] ) & next;
 isgood(a) || next;
 my( t = try2complete( N, a, L ));
 t & return(t);
)}




More information about the SeqFan mailing list