# How to ask WolframAlpha to find 'x such that p=32*x+1 is prime'

wojteo 06/12/2018. 4 answers, 1.295 views

I want to find prime $p$ in form of $p=32 x+1$ How can I ask WolframAlpha for such $x$ that will fulfil this equation?

EDIT: let's say that $100$ or $n$ solutions is enough for me

EDIT2: I need x's to be integers

Fraccalo 06/12/2018.

With MMA, say you want to check the first "n" x values:

n = 100;
Select[{#, 32*# + 1} & /@ Range[n], PrimeQ[#[[2]]] &]

{{3, 97}, {6, 193}, {8, 257}, {11, 353}, {14, 449}, {18, 577}, {20, 641}, {21, 673}, {24, 769}, {29, 929}, {36, 1153}, {38, 1217}, {39, 1249}, {44, 1409}, {50, 1601}, {53, 1697}, {59, 1889}, {63, 2017}, {65, 2081}, {66, 2113}, {71, 2273}, {81, 2593}, {83, 2657}, {84, 2689}, {86, 2753}, {95, 3041}, {98, 3137}, {99, 3169}}

and this if you want both x and p to be primes:

n = 100;
Select[{#, 32*# + 1} & /@ Range[n], And @@ PrimeQ[#] &]

{{3, 97}, {11, 353}, {29, 929}, {53, 1697}, {59, 1889}, {71, 2273}, {83, 2657}}

Edit: note that I'm assuming x to be integer. For x being a real number, there are more solutions.

Edit 2: For having solution for a generic x, just change the code to:

n = 100;
Select[{#, 32*# + 1} & /@ Range[0, n, 1/32], PrimeQ[#[[2]]] &]

{{1/32, 2}, {1/16, 3}, {1/8, 5}, {3/16, 7}, {5/16, 11}, {3/8, 13}, {1/ 2, 17}, {9/16, 19}, {11/16, 23}, {7/8, 29}, {15/16, 31}, {9/8, 37}, {5/4, 41}, {21/16, 43}, {23/16, 47}, {13/8, 53}, {29/16, 59}, {15/8, 61}, {33/16, 67}, {35/16, 71}, {9/4, 73}, {39/16, 79}, {41/16, 83}, {11/4, 89}, {3, 97}, {25/8, 101}, {51/16, 103}, {53/16, 107}, {27/8, 109}, {7/2, 113}, {63/16, 127}, {65/16, 131}, {17/4, 137}, {69/16, 139}, {37/8, 149}, {75/16, 151}, {39/8, 157}, {81/16, 163}, {83/16, 167}, {43/8, 173}, {89/16, 179}, {45/8, 181}, {95/16, 191}, {6, 193}, {49/8, 197}, {99/16, 199}, {105/16, 211}, {111/16, 223}, {113/16, 227}, {57/8, 229}, {29/4, 233}, {119/ 16, 239}, {15/2, 241}, {125/16, 251}, {8, 257}, {131/16, 263}, {67/ 8, 269}, {135/16, 271}, {69/8, 277}, {35/4, 281}, {141/16, 283}, {73/8, 293}, {153/16, 307}, {155/16, 311}, {39/4, 313}, {79/8, 317}}

rhermans 06/12/2018.

## General

There are as many solutions as prime numbers

If you Solve for $x$

Solve[32 x + 1 == p, x]
1/32 (-1 + p)

For every prime $p$ there will be an $x = \frac{p-1}{32}$ that satisfies.

## For any rational $x$

To see the firsts values you can use ReplaceAll on p with the first 100 Prime numbers, to get the first 100 values of $x$ that fulfill the equation

1/32 (-1 + p) /. p -> Prime[Range[100]]

Or we can generate a Table of the first 20 pairs $(p,x)$ with nice TableForm TableHeadings

TableForm[
Table[{p, (p-1)/32}, {p, Prime[Range[20]]}]
, TableHeadings -> {Automatic, {"p", "x"}}
]

## For integer $x$

These are the first 100 pairs $(p,x)$ fulfilling the equation for integer values for $x$

Block[{list = {}, p, x, counter = 1},
While[
Length[list] < 100,
p = Prime[counter];
x = (p - 1)/32;
If[IntegerQ[x], AppendTo[list, {p, x}]];
counter += 1;
];
list
]
{{97, 3}, {193, 6}, {257, 8}, {353, 11}, {449, 14}, {577, 18}, {641,
20}, {673, 21}, {769, 24}, {929, 29}, {1153, 36}, {1217, 38}, {1249,
39}, {1409, 44}, {1601, 50}, {1697, 53}, {1889, 59}, {2017,
63}, {2081, 65}, {2113, 66}, {2273, 71}, {2593, 81}, {2657,
83}, {2689, 84}, {2753, 86}, {3041, 95}, {3137, 98}, {3169,
99}, {3329, 104}, {3361, 105}, {3457, 108}, {3617, 113}, {4001,
125}, {4129, 129}, {4289, 134}, {4481, 140}, {4513, 141}, {4673,
146}, {4801, 150}, {4993, 156}, {5153, 161}, {5281, 165}, {5441,
170}, {5569, 174}, {5857, 183}, {5953, 186}, {6113, 191}, {6337,
198}, {6529, 204}, {6689, 209}, {6977, 218}, {7297, 228}, {7393,
231}, {7457, 233}, {7489, 234}, {7649, 239}, {7681, 240}, {7841,
245}, {7873, 246}, {7937, 248}, {8161, 255}, {8353, 261}, {8513,
266}, {8609, 269}, {8641, 270}, {8737, 273}, {8929, 279}, {9281,
290}, {9377, 293}, {9473, 296}, {9601, 300}, {9697, 303}, {9857,
308}, {10177, 318}, {10273, 321}, {10337, 323}, {10369,
324}, {10433, 326}, {10529, 329}, {10657, 333}, {10753,
336}, {11329, 354}, {11393, 356}, {11489, 359}, {11617,
363}, {11681, 365}, {11777, 368}, {11969, 374}, {12097,
378}, {12161, 380}, {12289, 384}, {12577, 393}, {12641,
395}, {13121, 410}, {13217, 413}, {13249, 414}, {13313,
416}, {13441, 420}, {13537, 423}, {13633, 426}}

user6014 06/12/2018.

If you have Mathematica, you can use the FindInstance function, which by definition provides one (or many) solutions to a particular equation:

In[12]:= FindInstance[
32*x + 1 == p && Element[p, Primes], {x, p}, Integers]

Out[12]= {{x -> 183, p -> 5857}}

Edit: Replying to OP's edit, if you want 100 solutions you could use

FindInstance[ 32*x + 1 == p && Element[p, Primes], {x, p}, Integers, 100]

Let $prime(k)$ the k-th prime number, then ask WolframAlpha:

(prime(k)-1)/32 for k=1 to 100

You can even see in the results what are integers (just increase k to 1000 for instance). For $k=100$, the first 100 primes, those integers x-values are only $3,6,8,11,\text{and }14$.

The same result as proposed by @rhermans, but not using MMA.

You can get the table $(prime(k), x)$ by inputting in W|A:

Table {prime(k),(prime(k)-1)/32} for k=1 to 100