Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Hello, Everyone.
( or Refer : http://communities.ptc.com/message/154874#154874 )
Thanks in advance for your time and help.
Best Regards.
Solved! Go to Solution.
Neat. I was bored at lunchtime, so I thought I'd generalize things a little bit generate arbitrary k-tuples (defined by the required difference between the first member of the k-tuple and the other members).
Stuart
Use the output of PrimeTriplet as input. Run from the second to the last but one element and remove every triple where one of its numbers are included in the next triple. A function overlap(triple1, triple2) may be useful in doing so.
Alternative approach: lookup the prime before the first and the prime after the last element of your triple. If the difference of any of them to the center element of the triple is 6, discard it.
As the triplet selection algorithm already sorts the triplets in ascending order, it should be sufficient to just ensure that:
the first number in a triplet is greater then the last in the previous triplet
and
the last number in a triplet is less than the first number in the succeding triplet
Stuart
Oh, yes! That sure was too obvious and too easy for me too see
In the attached sheet I nevertheless had to resort to my alternative approach as I don't use the precalculated triples.
The routines are written so that the argument is either a scalar (highes prime number involved) or, as in Liu's routine, a vector of primes.
So if you want to collect all routines in one programm as in the original sheet, you would calculate the prime list only once.
Neat. I was bored at lunchtime, so I thought I'd generalize things a little bit generate arbitrary k-tuples (defined by the required difference between the first member of the k-tuple and the other members).
Stuart
Great work.
What shall I say - welcome back!
Your primes2() is twice as fast as the routine listPrimes() in my sheet and uses up less ressources - great!