Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hi,
I have a question and need help. Assuming that we have a set of Prime Numbers (from 5 to 37
in this case) Let's extract Twin Primes like as the Output below. (IN .MCD12)
Thanks in advance.
Regards,
Loi.
Solved! Go to Solution.
Loi Le wrote:
Thanks, Richard. Possibly I should have the update-question :
Just a top-of-the-head thing, but might be worth playing with. Makes use of the fact that 'triple primes' don't exist (unless you count 1,2,3), to avoid re-testing numbers.
Stuart
Sorry, but that's not correct. Twin primes are pairs of primes that differ by 2, so (23,29) is not a valid pair.
Thanks, Richard. Possibly I should have the update-question :
Makes use of the fact that 'triple primes' don't exist (unless you count 1,2,3), to avoid re-testing numbers.
Another 10^-9 C saving in global warming
Richard Jackson wrote:
Makes use of the fact that 'triple primes' don't exist (unless you count 1,2,3), to avoid re-testing numbers.Another 10^-9 C saving in global warming
A nanocoulomb? Sorry, guv, I never really got past pounds, shillings and pence. What's that in moles of electrons?
However, you neglected the effects of relativity on subjective time experience ... that' gotta be worth a couple of microseconds of anybody's time!
Stuart
Your answer is very completely to my question. Thanks a lot indeed.
Loi.
Nice function...... Impressed
Was going to propose an alternative, but I don't think I could.
Mike
Mike Armstrong wrote:
Nice function...... Impressed
Was going to propose an alternative, but I don't think I could.
Mike
Oy vey iz mir! Are my lessons forgotten so soon, already?
There's *always* an alternative to anything I suggest
There are a couple of tricks to finding alternatives.
One is to just look at it sniffily and pick holes in it. "Hah! It doesn't handle the (special case) pairs (2,3) & (3,5)!" (having, naturally, extended the prime sequence) and then noting that it doesn't pick up the true prime triplets (2,3,5) & (3,5,7), extend the idea into Prime Constellations - ie, some sequence of primes that spans the minimum distance according to some criteria, eg prime triplets can be of the form (p,p+2,p+6), (p,p+4,p+6), (p,p+6,p+12), etc. Having then sneered at my rather pathetic program, you can then produce the piece de resistance that knocks mine into a cocked hat.
An alternative viewpoint is to, as Jean would have said, draw inspiration from a worksheet by saying "Wow! I wonder if it's possible to extend that program to cover other cases!"; both views can lead to the same result. Depends whether competition is your forte or you have a temperament like a Labrador puppy newly promoted to 2nd Lt.
Or you could be like me, a cross between Scrooge and the Four Yorkshiremen. I were raised when you could count each clock cycle of t' CPU and every bit counted, but you try and tell the young people of today that ..... they won't believe you. So profligate waste, such as Richard's checking a number more than once, that may be acceptable if you've got gigs of RAM and Hz, just offends my sensibilities (well, that's a bit of an exaggeration, I've only got the one sensibility).
Which leads to another way of developing alternatives - take a trick out of Paul Dirac's book and look for the beauty or elegance in a method.
Stuart
Stuart,
After reading your post I thought "I'm not a Labrador puppy" and decided to write a function which would collect Triplet Primes, see below.
Then, I decided to do a little research into types of Prime numbers and realised that there are multiple types.
Which massivly deflated me and made me realsie I might be more of a Poodle than a Labrador
Mike
Mike Armstrong wrote:
Stuart,
After reading your post I thought "I'm not a Labrador puppy" and decided to write a function which would collect Triplet Primes, see below.
Then, I decided to do a little research into types of Prime numbers and realised that there are multiple types.
- Pairs
- Triplets
- Quadruplets
- Quintuplets
Which massivly deflated me and made me realsie I might be more of a Poodle than a Labrador
Mike
First, I should point (pun intended) that Poodles are No 2 in the dog intelligence stakes, whereas Labradors are No 7. So well done on your promotion! (I, being of Welsh extraction, am, of course, a Border Collie, although my wife puts me about twenty places lower than an Afghan Hound. 🙂 )
Second, the term Labrador Puppy is not at all derdogatory! They are enthusiastic, intelligent, full of boundless energy and totally optimistic, just like a Second Lieutenant ... well, apart from the intelligence bit - never give a 2nd Lt a map unless you want to get totally lost.
As to your problem, this is where Labrador Nature comes in handy, as you should view it as a Labrador would view a Brontosaurus(*) - a big collection of bones (unlike my Collie self, which does a quick 180 and applies full military power).
Stuart
(*) Yes, I know it's really an Apatosaurus, but I'm with Gould on this one.
Stuart Bruff wrote:
... First, I should point (pun intended) that Poodles are No 2 in the dog intelligence stakes, whereas Labradors are No 7. So well done on your promotion! (I, being of Welsh extraction, am, of course, a Border Collie, although my wife puts me about twenty places lower than an Afghan Hound. 🙂 )
... As to your problem, this is where Labrador Nature comes in handy, as you should view it as a Labrador would view a Brontosaurus(*) - a big collection of bones (unlike my Collie self, which does a quick 180 and applies full military power).
Actually, thinking about it for a few seconds, I guess this proves my wife's point, as a real Collie would simply give a flock of Brontosauri 'The Eye' and start herding them.
Second, the term Labrador Puppy is not at all derdogatory!
Especially if it's a very determined Labrador puppy
Interesting.
Are you trying to program this case now?
Mike
noting that it doesn't pick up the true prime triplets (2,3,5) & (3,5,7),
You said the only prime triplet was 1,2,3. I took you at your word there, and never even thought about it. It just goes to show that one should always think about what they are reading!
What a wasted opportunity to come up with a smart-ass reply
Edit: Oh God! The nanny-ware kicked in! Perhaps I'm supposed to say smart-donkey reply?
Richard Jackson wrote:
noting that it doesn't pick up the true prime triplets (2,3,5) & (3,5,7),You said the only prime triplet was 1,2,3. I took you at your word there, and never even thought about it. It just goes to show that one should always think about what they are reading!
What a wasted opportunity to come up with a smart-*** reply
Edit: Oh God! The nanny-ware kicked in! Perhaps I'm supposed to say smart-donkey reply?
I did say 'true' triplets, all the rest of them have are separated by more than 2. There are also some variations that I regard as cheating. For example, there are triplets that are consecutive primes but there are also other triplets that match a given pattern, but aren't consecutive (ie, there's one or more other primes in the minimum subsequence containing the triplet.
What a wasted opportunity to come up with a smart-*** reply
Edit: Oh God! The nanny-ware kicked in! Perhaps I'm supposed to say smart-donkey reply?
I'm shocked, Jackson, that you could impugn donkeys in such a way. Is it not enough that we denigrate cats, by attributing feminine malice to them, that we must now resort to defaming equus africanus asinus?
A friend of mine insists on a Right to Reply
I have a related question with the above, and need help.I wish to learn. ( IN .MCD12 ). Assuming that we have a set of Prime Numbers (from 41 to 59). Let's extract Twin Primes and Cousin Primes, and Non-of-those like as the Output below. (or the Output is a similar one).
Thanks in advance.
Loi.
Something like the attached?
Mike
Message was edited by: Mike Armstrong - Worksheet updated due to error
Thank you very much, Mike.
The reason, I need help with this, is I hope to find a way to write a function for Triplet Prime completely. And I have an extension of set of P need help. I hope you understand me. (The attached below).
Regards,
Loi.
I have just noticed an error in my function. 37 shouldn't be getting called up in the 'None of those' categories. I will modify the function to suit.
Do you now want to include Triplet Primes?
I will update my original worksheet to try and keep this thread as clean as possible!!!
Mike
Yes, please. If the output of your function include Triplet Primes, that is good for me, if it does not include Triplet Primes, anyway my question is answered.
Regards,
Loi.
I will have a look tomorrow.
Mike
Have a look at the attached sheet. I think it works.
It doesn't exclude the special case of Triplet primes.
The function is bulky and horrible at the moment and I will have a look at tidying it up.
Cheers
Mike
Mike,
My related question above, and my plan for "Prime Triplet" were answered.(from you, Mike !) (I hope you to understand me. Sometimes I really don't know how to "set-up" my question clearly and made you confused many times. Sorry about that.)
Thank you for your time and help.
Regards,
Loi.
Sometimes I really don't know how to "set-up" my question clearly and made you confused many times. Sorry about that.)
Don't worry, I confuse myself most of the time.
The function is over the top if you only want Prime Triplets, but if you continue to build the function, eventually it will be able to extract all Prime cases.
Mike
Mike, I have been helped from you with writting a function for Prime Triplets. And now I have a related query with the above, wish learning, and wish be helped with any suggestion. It's about: "Prime Triplets and Extracting Their Non-Overlap". Assume having a set of Prime Triplets from 5 to 317.
Thanks in advance.
Regards,
Loi.
Loi,
I will be more than happy to take a look, but I travel to Germany today and will not be able to access the Internet until tomorrow evening.
Mike
Hi,
I have a related question with the above, I am very interested in, wish learning, and need help.
Thank you in advance.
Regards,
Loi.