Talk:Successive prime differences: Difference between revisions

From Rosetta Code
Content added Content deleted
(Error in Python example for last group?)
 
(→‎Task background: Answered Calmosoft's question)
 
(13 intermediate revisions by 5 users not shown)
Line 1: Line 1:

==References==
Could you please add a title to the references as well as the link. Thanks. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 15:43, 28 April 2019 (UTC)


== Different results for 6,4,2 ==
== Different results for 6,4,2 ==


I am getting slightly different results for the last group than the Python example and am finding it hard to see where I may be wrong. I am finding 337 groups. Am I just mising something? --[[User:Thundergnat|Thundergnat]] ([[User talk:Thundergnat|talk]]) 01:20, 27 April 2019 (UTC)
I am getting slightly different results for the last group than the Python example and am finding it hard to see where I may be wrong. I am finding 337 groups. Am I just mising something? --[[User:Thundergnat|Thundergnat]] ([[User talk:Thundergnat|talk]]) 01:20, 27 April 2019 (UTC)

<pre>1: 7, 13, 17, 19
Doh! It's me, I glossed over the 'successive' part of the problem. Update to follow. --[[User:Thundergnat|Thundergnat]] ([[User talk:Thundergnat|talk]]) 01:25, 27 April 2019 (UTC)
2: 31, 37, 41, 43

3: 61, 67, 71, 73
==Task background==
4: 97, 103, 107, 109
It's my birthday soon so I googled my age and found:
5: 271, 277, 281, 283
* It's a prime.
6: 607, 613, 617, 619
* It's a twin prime.
7: 1291, 1297, 1301, 1303

8: 1657, 1663, 1667, 1669
I searched Rosetta Code and found that there was no twin prime task! (I had expected that someone would have already started it). I resolved to wait until closer to my birthday then put up a twin primes task and left it at that.
9: 1777, 1783, 1787, 1789

10: 1861, 1867, 1871, 1873
A few days later I started to think of what a generalisation around the idea of twin primes would be and hit on a difference; then multiple differences; then really liked how my solution to generating a sliding group of <nowiki><count></nowiki> items from a list actually did come from the Python fundamentals:
11: 1867, 1873, 1877, 1879
:<lang python>zip(*(lst[n:] for n in range(count)))</lang>
12: 1987, 1993, 1997, 1999

13: 2131, 2137, 2141, 2143
I finished the code and played with the differences then firmed up what the task details would become. I wrote the task and added extra explanations and emphasis to try and help the reader grasp the details, then went to bed.
14: 2371, 2377, 2381, 2383

15: 2677, 2683, 2687, 2689
Today I've just done a search of the primes generated from differences of <code>2, 4</code> on OEIS to find that it is [https://oeis.org/A275515 known] to some degree, but expressed differently and not as generally as here - I guess recreational maths peeps think alike :-)
16: 2791, 2797, 2801, 2803

17: 3457, 3463, 3467, 3469
Enjoy. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 06:54, 27 April 2019 (UTC)
18: 4507, 4513, 4517, 4519
:It is very well studied, but you must state it slightly differently. Let P2 be the infinite sequence of successive primes (p2_a,P2_b) such that P2_b-P2_a=2. and P4 be the similar infinite sequence (P4_a,P4_b) such that P4_b-P4_a = 4. The your generalization to P2P4 as 3 successive primes with Pa,Pb,Pc with Pb-Pa=2 and Pc-Pb=4 is a search through P2 and P4 to find P2_b=P4_a. An interesting study would be to compute over a large range the length of P2 and P4 and thus predict the length of P2P4. For a given range should the length of P2P4 be the same as P4P2?--[[User:Nigel Galloway|Nigel Galloway]] ([[User talk:Nigel Galloway|talk]]) 13:28, 27 April 2019 (UTC)
19: 5407, 5413, 5417, 5419

20: 5431, 5437, 5441, 5443
:: I was going to add a twin prime task &nbsp; (and cousin prime task, a difference of four), &nbsp; but was somewhat preempted with addition of the &nbsp; ''sexy prime'' &nbsp; task &nbsp; (a difference of six), &nbsp; so I dithered a bit. &nbsp; There are other named difference primes such as &nbsp; ''devil'' &nbsp; (also called &nbsp; ''beast''), &nbsp; ''centennial'', &nbsp; and &nbsp; ''millennial'' &nbsp; primes. &nbsp; However, having a Rosetta Code task just for twin primes would make the code a &nbsp; lot &nbsp; cleaner and simpler, &nbsp; not to mention faster. &nbsp; This would've made the task solutions more easier to compare &nbsp; (and I think more useful for people who wanted a clean and robust code for just concerning the generation of twin primes). &nbsp; Plus it would be easier to find when people are looking for a simple twin prime generator. &nbsp; &nbsp; -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 21:25, 27 April 2019 (UTC)
21: 5641, 5647, 5651, 5653

22: 5647, 5653, 5657, 5659
:: I googled my age, and found it to be &nbsp; ''highly totient''. &nbsp; &nbsp; And I'll never be &nbsp; ''highly totient''. &nbsp; again. &nbsp; Sigh. &nbsp; &nbsp; -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 21:38, 27 April 2019 (UTC)
23: 7867, 7873, 7877, 7879
::: I enjoyed the google to work that out :-) <br>--[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 06:06, 28 April 2019 (UTC)
24: 9001, 9007, 9011, 9013

25: 11821, 11827, 11831, 11833
Is the first solution for 6,4,2 not '''7,13,17,19'''?--[[User:CalmoSoft|CalmoSoft]] ([[User talk:CalmoSoft|talk]]) 10:40, 7 September 2021 (UTC)
26: 13681, 13687, 13691, 13693
:No, because the next prime after 7 is 11. --[[User:Tigerofdarkness|Tigerofdarkness]] ([[User talk:Tigerofdarkness|talk]]) 11:30, 7 September 2021 (UTC)
27: 14551, 14557, 14561, 14563
28: 15727, 15733, 15737, 15739
29: 16057, 16063, 16067, 16069
30: 17377, 17383, 17387, 17389
31: 18121, 18127, 18131, 18133
32: 18301, 18307, 18311, 18313
33: 19417, 19423, 19427, 19429
34: 20347, 20353, 20357, 20359
35: 21481, 21487, 21491, 21493
36: 22147, 22153, 22157, 22159
37: 24097, 24103, 24107, 24109
38: 27271, 27277, 27281, 27283
39: 32707, 32713, 32717, 32719
40: 35521, 35527, 35531, 35533
41: 36781, 36787, 36791, 36793
42: 37561, 37567, 37571, 37573
43: 41221, 41227, 41231, 41233
44: 41947, 41953, 41957, 41959
45: 42397, 42403, 42407, 42409
46: 42451, 42457, 42461, 42463
47: 43777, 43783, 43787, 43789
48: 44257, 44263, 44267, 44269
49: 47137, 47143, 47147, 47149
50: 50581, 50587, 50591, 50593
51: 55207, 55213, 55217, 55219
52: 55807, 55813, 55817, 55819
53: 55921, 55927, 55931, 55933
54: 56467, 56473, 56477, 56479
55: 57781, 57787, 57791, 57793
56: 62131, 62137, 62141, 62143
57: 65707, 65713, 65717, 65719
58: 68437, 68443, 68447, 68449
59: 69991, 69997, 70001, 70003
60: 70111, 70117, 70121, 70123
61: 74707, 74713, 74717, 74719
62: 75991, 75997, 76001, 76003
63: 79621, 79627, 79631, 79633
64: 79687, 79693, 79697, 79699
65: 80671, 80677, 80681, 80683
66: 83221, 83227, 83231, 83233
67: 84307, 84313, 84317, 84319
68: 85081, 85087, 85091, 85093
69: 87547, 87553, 87557, 87559
70: 88651, 88657, 88661, 88663
71: 88801, 88807, 88811, 88813
72: 88807, 88813, 88817, 88819
73: 91801, 91807, 91811, 91813
74: 93481, 93487, 93491, 93493
75: 98887, 98893, 98897, 98899
76: 101107, 101113, 101117, 101119
77: 101197, 101203, 101207, 101209
78: 102667, 102673, 102677, 102679
79: 106207, 106213, 106217, 106219
80: 106531, 106537, 106541, 106543
81: 110557, 110563, 110567, 110569
82: 113011, 113017, 113021, 113023
83: 113161, 113167, 113171, 113173
84: 115771, 115777, 115781, 115783
85: 118891, 118897, 118901, 118903
86: 124291, 124297, 124301, 124303
87: 124771, 124777, 124781, 124783
88: 125107, 125113, 125117, 125119
89: 126481, 126487, 126491, 126493
90: 131701, 131707, 131711, 131713
91: 132751, 132757, 132761, 132763
92: 134581, 134587, 134591, 134593
93: 135271, 135277, 135281, 135283
94: 139291, 139297, 139301, 139303
95: 143821, 143827, 143831, 143833
96: 146977, 146983, 146987, 146989
97: 148921, 148927, 148931, 148933
98: 150211, 150217, 150221, 150223
99: 151597, 151603, 151607, 151609
100: 155371, 155377, 155381, 155383
101: 160081, 160087, 160091, 160093
102: 162517, 162523, 162527, 162529
103: 163981, 163987, 163991, 163993
104: 167107, 167113, 167117, 167119
105: 170341, 170347, 170351, 170353
106: 176041, 176047, 176051, 176053
107: 176497, 176503, 176507, 176509
108: 177421, 177427, 177431, 177433
109: 178807, 178813, 178817, 178819
110: 178897, 178903, 178907, 178909
111: 192877, 192883, 192887, 192889
112: 198817, 198823, 198827, 198829
113: 203311, 203317, 203321, 203323
114: 203761, 203767, 203771, 203773
115: 205651, 205657, 205661, 205663
116: 207511, 207517, 207521, 207523
117: 209257, 209263, 209267, 209269
118: 209347, 209353, 209357, 209359
119: 210901, 210907, 210911, 210913
120: 211867, 211873, 211877, 211879
121: 219931, 219937, 219941, 219943
122: 221707, 221713, 221717, 221719
123: 223747, 223753, 223757, 223759
124: 223831, 223837, 223841, 223843
125: 228511, 228517, 228521, 228523
126: 230761, 230767, 230771, 230773
127: 233911, 233917, 233921, 233923
128: 234181, 234187, 234191, 234193
129: 237151, 237157, 237161, 237163
130: 243577, 243583, 243587, 243589
131: 244291, 244297, 244301, 244303
132: 249427, 249433, 249437, 249439
133: 251191, 251197, 251201, 251203
134: 252817, 252823, 252827, 252829
135: 257857, 257863, 257867, 257869
136: 261631, 261637, 261641, 261643
137: 264127, 264133, 264137, 264139
138: 266671, 266677, 266681, 266683
139: 266677, 266683, 266687, 266689
140: 267511, 267517, 267521, 267523
141: 267637, 267643, 267647, 267649
142: 268771, 268777, 268781, 268783
143: 269377, 269383, 269387, 269389
144: 272257, 272263, 272267, 272269
145: 272341, 272347, 272351, 272353
146: 275911, 275917, 275921, 275923
147: 276037, 276043, 276047, 276049
148: 278491, 278497, 278501, 278503
149: 281641, 281647, 281651, 281653
150: 282091, 282097, 282101, 282103
151: 284731, 284737, 284741, 284743
152: 284737, 284743, 284747, 284749
153: 290611, 290617, 290621, 290623
154: 296551, 296557, 296561, 296563
155: 298681, 298687, 298691, 298693
156: 305401, 305407, 305411, 305413
157: 311737, 311743, 311747, 311749
158: 312931, 312937, 312941, 312943
159: 313981, 313987, 313991, 313993
160: 315691, 315697, 315701, 315703
161: 317257, 317263, 317267, 317269
162: 322237, 322243, 322247, 322249
163: 323371, 323377, 323381, 323383
164: 331537, 331543, 331547, 331549
165: 332461, 332467, 332471, 332473
166: 337861, 337867, 337871, 337873
167: 340927, 340933, 340937, 340939
168: 344161, 344167, 344171, 344173
169: 348451, 348457, 348461, 348463
170: 354031, 354037, 354041, 354043
171: 354247, 354253, 354257, 354259
172: 355507, 355513, 355517, 355519
173: 357727, 357733, 357737, 357739
174: 363361, 363367, 363371, 363373
175: 365461, 365467, 365471, 365473
176: 375091, 375097, 375101, 375103
177: 375247, 375253, 375257, 375259
178: 376921, 376927, 376931, 376933
179: 382861, 382867, 382871, 382873
180: 384247, 384253, 384257, 384259
181: 388471, 388477, 388481, 388483
182: 388891, 388897, 388901, 388903
183: 389161, 389167, 389171, 389173
184: 391387, 391393, 391397, 391399
185: 393571, 393577, 393581, 393583
186: 393847, 393853, 393857, 393859
187: 394357, 394363, 394367, 394369
188: 399271, 399277, 399281, 399283
189: 400237, 400243, 400247, 400249
190: 402751, 402757, 402761, 402763
191: 402757, 402763, 402767, 402769
192: 411001, 411007, 411011, 411013
193: 414697, 414703, 414707, 414709
194: 416407, 416413, 416417, 416419
195: 416491, 416497, 416501, 416503
196: 417721, 417727, 417731, 417733
197: 419047, 419053, 419057, 419059
198: 420307, 420313, 420317, 420319
199: 422077, 422083, 422087, 422089
200: 424261, 424267, 424271, 424273
201: 427237, 427243, 427247, 427249
202: 428137, 428143, 428147, 428149
203: 428557, 428563, 428567, 428569
204: 429271, 429277, 429281, 429283
205: 430741, 430747, 430751, 430753
206: 431857, 431863, 431867, 431869
207: 434377, 434383, 434387, 434389
208: 444517, 444523, 444527, 444529
209: 447817, 447823, 447827, 447829
210: 449557, 449563, 449567, 449569
211: 451657, 451663, 451667, 451669
212: 453631, 453637, 453641, 453643
213: 463447, 463453, 463457, 463459
214: 464131, 464137, 464141, 464143
215: 470077, 470083, 470087, 470089
216: 473191, 473197, 473201, 473203
217: 481837, 481843, 481847, 481849
218: 488197, 488203, 488207, 488209
219: 498391, 498397, 498401, 498403
220: 500167, 500173, 500177, 500179
221: 510067, 510073, 510077, 510079
222: 516151, 516157, 516161, 516163
223: 517501, 517507, 517511, 517513
224: 520957, 520963, 520967, 520969
225: 521167, 521173, 521177, 521179
226: 521527, 521533, 521537, 521539
227: 524341, 524347, 524351, 524353
228: 529681, 529687, 529691, 529693
229: 539101, 539107, 539111, 539113
230: 541537, 541543, 541547, 541549
231: 543877, 543883, 543887, 543889
232: 550651, 550657, 550661, 550663
233: 556261, 556267, 556271, 556273
234: 558781, 558787, 558791, 558793
235: 560227, 560233, 560237, 560239
236: 561091, 561097, 561101, 561103
237: 565381, 565387, 565391, 565393
238: 566431, 566437, 566441, 566443
239: 567871, 567877, 567881, 567883
240: 567937, 567943, 567947, 567949
241: 569071, 569077, 569081, 569083
242: 571861, 571867, 571871, 571873
243: 576211, 576217, 576221, 576223
244: 585031, 585037, 585041, 585043
245: 594151, 594157, 594161, 594163
246: 595951, 595957, 595961, 595963
247: 596851, 596857, 596861, 596863
248: 603907, 603913, 603917, 603919
249: 609607, 609613, 609617, 609619
250: 610837, 610843, 610847, 610849
251: 611827, 611833, 611837, 611839
252: 620227, 620233, 620237, 620239
253: 623671, 623677, 623681, 623683
254: 626611, 626617, 626621, 626623
255: 626617, 626623, 626627, 626629
256: 628207, 628213, 628217, 628219
257: 630577, 630583, 630587, 630589
258: 637717, 637723, 637727, 637729
259: 644857, 644863, 644867, 644869
260: 645571, 645577, 645581, 645583
261: 653197, 653203, 653207, 653209
262: 660061, 660067, 660071, 660073
263: 662941, 662947, 662951, 662953
264: 663967, 663973, 663977, 663979
265: 666427, 666433, 666437, 666439
266: 666637, 666643, 666647, 666649
267: 669667, 669673, 669677, 669679
268: 669847, 669853, 669857, 669859
269: 679741, 679747, 679751, 679753
270: 682141, 682147, 682151, 682153
271: 687007, 687013, 687017, 687019
272: 697681, 697687, 697691, 697693
273: 704017, 704023, 704027, 704029
274: 715867, 715873, 715877, 715879
275: 724111, 724117, 724121, 724123
276: 727261, 727267, 727271, 727273
277: 735061, 735067, 735071, 735073
278: 736357, 736363, 736367, 736369
279: 737281, 737287, 737291, 737293
280: 743167, 743173, 743177, 743179
281: 745741, 745747, 745751, 745753
282: 746497, 746503, 746507, 746509
283: 746737, 746743, 746747, 746749
284: 750151, 750157, 750161, 750163
285: 752281, 752287, 752291, 752293
286: 759547, 759553, 759557, 759559
287: 767857, 767863, 767867, 767869
288: 770047, 770053, 770057, 770059
289: 776551, 776557, 776561, 776563
290: 779341, 779347, 779351, 779353
291: 783781, 783787, 783791, 783793
292: 786691, 786697, 786701, 786703
293: 795931, 795937, 795941, 795943
294: 812341, 812347, 812351, 812353
295: 823231, 823237, 823241, 823243
296: 823717, 823723, 823727, 823729
297: 828691, 828697, 828701, 828703
298: 831361, 831367, 831371, 831373
299: 832621, 832627, 832631, 832633
300: 837367, 837373, 837377, 837379
301: 837667, 837673, 837677, 837679
302: 841921, 841927, 841931, 841933
303: 849721, 849727, 849731, 849733
304: 855721, 855727, 855731, 855733
305: 855727, 855733, 855737, 855739
306: 859267, 859273, 859277, 859279
307: 881527, 881533, 881537, 881539
308: 882241, 882247, 882251, 882253
309: 891481, 891487, 891491, 891493
310: 891817, 891823, 891827, 891829
311: 894997, 895003, 895007, 895009
312: 896101, 896107, 896111, 896113
313: 900577, 900583, 900587, 900589
314: 908851, 908857, 908861, 908863
315: 911161, 911167, 911171, 911173
316: 916177, 916183, 916187, 916189
317: 924031, 924037, 924041, 924043
318: 930277, 930283, 930287, 930289
319: 935581, 935587, 935591, 935593
320: 937627, 937633, 937637, 937639
321: 942031, 942037, 942041, 942043
322: 942847, 942853, 942857, 942859
323: 944137, 944143, 944147, 944149
324: 944887, 944893, 944897, 944899
325: 950221, 950227, 950231, 950233
326: 957031, 957037, 957041, 957043
327: 959461, 959467, 959471, 959473
328: 959467, 959473, 959477, 959479
329: 960637, 960643, 960647, 960649
330: 962671, 962677, 962681, 962683
331: 964207, 964213, 964217, 964219
332: 978067, 978073, 978077, 978079
333: 978337, 978343, 978347, 978349
334: 980887, 980893, 980897, 980899
335: 986137, 986143, 986147, 986149
336: 994297, 994303, 994307, 994309
337: 997141, 997147, 997151, 997153</pre>

Latest revision as of 11:31, 7 September 2021

References

Could you please add a title to the references as well as the link. Thanks. --Paddy3118 (talk) 15:43, 28 April 2019 (UTC)

Different results for 6,4,2

I am getting slightly different results for the last group than the Python example and am finding it hard to see where I may be wrong. I am finding 337 groups. Am I just mising something? --Thundergnat (talk) 01:20, 27 April 2019 (UTC)

Doh! It's me, I glossed over the 'successive' part of the problem. Update to follow. --Thundergnat (talk) 01:25, 27 April 2019 (UTC)

Task background

It's my birthday soon so I googled my age and found:

  • It's a prime.
  • It's a twin prime.

I searched Rosetta Code and found that there was no twin prime task! (I had expected that someone would have already started it). I resolved to wait until closer to my birthday then put up a twin primes task and left it at that.

A few days later I started to think of what a generalisation around the idea of twin primes would be and hit on a difference; then multiple differences; then really liked how my solution to generating a sliding group of <count> items from a list actually did come from the Python fundamentals:

<lang python>zip(*(lst[n:] for n in range(count)))</lang>

I finished the code and played with the differences then firmed up what the task details would become. I wrote the task and added extra explanations and emphasis to try and help the reader grasp the details, then went to bed.

Today I've just done a search of the primes generated from differences of 2, 4 on OEIS to find that it is known to some degree, but expressed differently and not as generally as here - I guess recreational maths peeps think alike :-)

Enjoy. --Paddy3118 (talk) 06:54, 27 April 2019 (UTC)

It is very well studied, but you must state it slightly differently. Let P2 be the infinite sequence of successive primes (p2_a,P2_b) such that P2_b-P2_a=2. and P4 be the similar infinite sequence (P4_a,P4_b) such that P4_b-P4_a = 4. The your generalization to P2P4 as 3 successive primes with Pa,Pb,Pc with Pb-Pa=2 and Pc-Pb=4 is a search through P2 and P4 to find P2_b=P4_a. An interesting study would be to compute over a large range the length of P2 and P4 and thus predict the length of P2P4. For a given range should the length of P2P4 be the same as P4P2?--Nigel Galloway (talk) 13:28, 27 April 2019 (UTC)
I was going to add a twin prime task   (and cousin prime task, a difference of four),   but was somewhat preempted with addition of the   sexy prime   task   (a difference of six),   so I dithered a bit.   There are other named difference primes such as   devil   (also called   beast),   centennial,   and   millennial   primes.   However, having a Rosetta Code task just for twin primes would make the code a   lot   cleaner and simpler,   not to mention faster.   This would've made the task solutions more easier to compare   (and I think more useful for people who wanted a clean and robust code for just concerning the generation of twin primes).   Plus it would be easier to find when people are looking for a simple twin prime generator.     -- Gerard Schildberger (talk) 21:25, 27 April 2019 (UTC)
I googled my age, and found it to be   highly totient.     And I'll never be   highly totient.   again.   Sigh.     -- Gerard Schildberger (talk) 21:38, 27 April 2019 (UTC)
I enjoyed the google to work that out :-)
--Paddy3118 (talk) 06:06, 28 April 2019 (UTC)

Is the first solution for 6,4,2 not 7,13,17,19?--CalmoSoft (talk) 10:40, 7 September 2021 (UTC)

No, because the next prime after 7 is 11. --Tigerofdarkness (talk) 11:30, 7 September 2021 (UTC)