Talk:Successive prime differences: Difference between revisions

From Rosetta Code
Content added Content deleted
Line 5: Line 5:


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)
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)

==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 untill 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 <nowiki><count></nowiki> 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 <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 :-)

Enjoy. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 06:54, 27 April 2019 (UTC)

Revision as of 06:54, 27 April 2019

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 untill 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)