a(n-2) | (a(n)+a(n-1)): only primes

Peter Pein petsie at dordos.net
Mon Jan 8 11:51:28 CET 2007


Antti Karttunen schrieb:
> Peter Pein wrote:
> 
>> zak seidov schrieb:
>>  
>>
>>> Dear seqfans,
>>>
>>> Anyone with C++ may wish to add more terms?
>>>
>>> Thanks, Zak
>>>
>>> %S A000001
>>> 2,3,5,7,3,11,7,37,5,439,11,7013,379,27673,373,54973,977,548753,4229,7678313,10009,230339381,27763,5067438619,197297
>>>
>>> %N A000001 a(1) =2 , a(2) = 3, a(n) = least prime such
>>> that a(n-2) | (a(n)+a(n-1))
>>> %A A000001 Zak Seidov  (zakseidov at gmail.com), Jan 07
>>> 2007
>>>
>>>   
>> Sorry,
>>
>> I do not understand, why a(3) = 5 > 3, because 2 | (3 + 3)
>> ??
>>  
>>
> I think it's a hidden unconscious assumption we are all sometimes guilty
> of. In this case: "and different from the previous term".
> 
> -- Antti
> 
>> Peter
>>

But even then, (7013 + 5) / 11 = 638.

379 is the seventh prime with mod(7013 + p, 11) = 0:

Select[Prime[Range at PrimePi[500]],Mod[7013+#,11]==0&]
--> {5, 71, 137, 181, 269, 313, 379, 401, 467}


anList[n_ /; n >= 3] :=
  Nest[Append[#1,
     Function[lst, Module[{a2, a1},
        {a2, a1} = lst;
         NestWhile[
          #1 + a2 & ,
          a2 - Mod[a1, a2],
          #1 < 2 || #1 ===a1 || Mod[#1 + a1, a2] =!= 0 || !PrimeQ[#1] &]
     ]][Take[#1, -2]]] & ,
   {2, 3}, n]

lst50 = anList[50]
-->
{2, 3, 5, 7, 3, 11, 7, 37, 5, 439, 11, 7013, 5, 42073, 2, 42071, 3, 168281, 7,
 673117, 3, 21539741, 7, 86158957, 11, 344635817, 2, 1723179083, 3, 892716329,
 7, 165425191889, 29, 7278708443087, 19, 43672250658503, 71, 2183612532925079,
 829, 183423452765705807, 11, 13573335504662229707, 7, 244320039083920134719,
 29, 488640078167840269409, 113, 12704642032363847004521, 881,
 863915658200741596306547, 1093, 5183493949204449577838189}

Union[Apply[Mod[#2 + #3, #1] & , Partition[lst50, 3, 1], {1}]]

--> {0}






More information about the SeqFan mailing list