[seqfan] Re: A214089

Olivier Gerard olivier.gerard at gmail.com
Sun Aug 19 08:41:56 CEST 2012


Dear Jonathan,

You can look at the modifications made by T.D. Noe on your code in the
sequence's published entry.

Olivier


On Sun, Aug 19, 2012 at 5:50 AM, Jonathan Stauduhar <jstdhr at gmail.com> wrote:
> Hi All,
>
> I have developed an algorithm for extending A214089
> <https://oeis.org/A214089>.  I am trying to write a Mathematica program that
> implements this algorithm, but I am woefully inept.  Is there someone who
> might be interested in helping me get the following inelegant code working?
>
> f[n_] :=
>   Block[{k = 1, p = Times @@ Prime at Range@n},
>    While[! IntegerQ at Sqrt[4 k*p + 1], k++];
>    If[! PrimeQ[Sqrt[4 k*p + 1]], (* not a prime yet, so process further *)
>     Block[{j = 1, r = p, x = Floor at Sqrt[k*r] , y = x * (x + 1)},
>      While[True,
>       If[IntegerQ at Sqrt[(y + (j*r)) + 1], (*if it's an integer, check for
> primality*)
>        If[PrimeQ at Sqrt[(y + (j*r)) + 1], (*if it's prime it's a solution, so
> move on to next term*)
>          Print[Sqrt[(y + (j*r)) + 1]];
>          Sqrt[(y + (j*r)) + 1]; Break[]
>         ]
>       ];
>       j++
>      ] (*end while*)
>     ] (*end block*)
>    ];
>    Sqrt[4 k*p + 1]]; (* it's prime, so it's a solution *)
>
> Array[f, 8]
>
> The output is:
>
> 315589
> {3, 5, 11, 29, 419, 1429, 1429, 125971}
>
> The first seven terms in the array are correct, but the eighth is not.  The
> eighth term should be 315589.  The problem is that the value correctly
> calculated by "Sqrt[(y + (j*r)) + 1]" on line 10 isn't being added to the
> array.
>
> Thanks,
>
> Jonathan
>
>
>
>
> _______________________________________________
>
> Seqfan Mailing list - http://list.seqfan.eu/



More information about the SeqFan mailing list