Message Boards Message Boards

0
|
384 Views
|
8 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How can i append the value of a variable from a program and create a new list to compute

sq=Table[j,{j,1000000}]
    sq11=Table[j,{j,1,2000}]
    x=Select[sq,IntegerQ,(1005)]
    n=Select[sq,PrimeQ,(1005)]
    a=n-(Mod[n,x])
    b=n-a
    c=a+b
    d=Mod[x,n]
    h=Differences[a]
    j={1}
    hh=Prepend[h,j]
    Count[h, 5]
    f = Table[{ n[[i - 1]]},{i,1,Length[n]}]
    f1 = Table[{ n[[i - 2]]},{i,1,Length[n]}]
    f2 = Table[{ n[[i - 3]]},{i,1,Length[n]}]
    h = Table[{ x[[i - 1]]},{i,1,Length[x]}]
    h1 = Table[{ x[[i - 2]]},{i,1,Length[x]}]
    h2 = Table[{ x[[i - 3]]},{i,1,Length[x]}]
    k=Mod[f,h1]
    k1=Mod[f1,h2]
    kk=Mod[f,h]
    ee=hh*x
    e=((hh*x)+d)-f
    k-k1
    l=(ee+kk)-f
    m=l+(f1-f)
    fg = Table[{ m[[i - 1]]},{i,1,Length[n]}]
    fg1 = Table[{ m[[i - 2]]},{i,1,Length[n]}]
    fg2 = Table[{ m[[i - 3]]},{i,1,Length[n]}]
    n=-l-((fg-fg1)*2)-((k1-k)*2)+2
    n1=-l-((fg-fg1)*2)+((k1-k)*2)+2
    p=(n-n1)/4
    o=b+a
    q=f[[-2]]
    r=p[[-1]]
    b1=kk[[-2]]
    s=b1+r
    s1=ee[[-2]]
    t=s+s1

In the above program how can i get the value of t to append to f1 and use it from f,f1,f2 and after to get to a new value of t every time i loop ....?

8 Replies

... how can i get the value of t to append to f1...

Append[f1, t]    (* returns a copy of the list f1 with t added to the end *)
AppendTo[f1, t] (* changes f1 to be the value of Append[f1, t] *)

... use it from f,f1,f2 and after to get to a new value of t every time i loop?

I don't know what this means. My hope is that Append or AppendTo will help you figure out the answer yourself.

POSTED BY: Michael Rogers
Posted 1 month ago

What are you trying to do? This code is a mess. Have you even actually looked at the stuff you're creating? Like, do you realize that f1 contains an element like {List}? Also, why so many superfluous variables? Like c is just n, and c is never used. d is just x. And there are much easier ways to create these expressions. x could have just been Range[1005] and n could have been Prime[x]. And what "loop" are you referring to? How are we supposed to know what loop you're going to want to do? Maybe you can reduce the size of the problem (something like 5 instead of 1005), show us the expressions you're trying to create, and then ask how to get to that. Some explanation of the semantics would also help.

POSTED BY: Eric Rimbey

All i want is to change the llist n to a new list and add the value of the variable "t" to o[[-1]] and start it all over again until the length of o gets to 1020

this pattern is predictible it keeps going on and on

I do not know how the pen-n-paper calculations relate to the posted code, but the following reproduces the computations I see on the paper:

nlist = Range[1000, 1010];
plist = Prime[nlist];
dp = plist // Differences
dp7n = plist - 7 nlist // Differences // Abs
dp - dp7n // Abs
POSTED BY: Michael Rogers

On my program it is "p" that gives the numbers on circles at the right of the paper, If you sum P to the previous 9__ number and you sum to 7*the position,for these selected numbers you get the next prime number...

    **strong text**mathematica
    ( Defining the ordered pairs )
    pairs = {{8, 1}, {10, 3}, {12, 5}, {14, 7}, {16, 9}, {18, 11}, {20, 13}, {22, 15}, {24, 
    17}, {26, 19}, {28, 21}, {30, 23}};
    ( Function to verify if a is prime )
    isPrimeZ[x_, y_] := Module[{z},
     z = 7000 + 914 + y;
     z == 7907 + x && PrimeQ[z]
     ];
    ( Filttering the pairs that satisfy the conditiom)
    results = Select[pairs, isPrimeZ[#[[1]], #[[2]]] &];
    ( Exihibiting the results)
    results
    {{12,5},{20,13},{26,19},{30,23}}. This is what is behind my attempt to program...it is another way tô face the problem...the prime numbers are predictable and follow a Pattern 
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract