Mathematica novice here.

I want to start with a list of integers that are the product of three distinct primes m,n, and o, where 2 <= m|n|o < 2000.

Sort[Times @@@ Subsets[Select[Range[2000], PrimeQ], {3}]]

How do I find the longest subsequence within this list that consists of consecutive integers?

  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Dr. belisarius Nov 6 '14 at 19:30
  • $\begingroup$ Thanks - I should have included the follow up in the original question. How can I make it better at this point? $\endgroup$ – pgblu Nov 6 '14 at 19:31
  • $\begingroup$ Your current question looks bad. The title refers to "consecutive integers" and the body to "consecutive primes". Please take your time to think your questions so you don't waste other peoples'. $\endgroup$ – Dr. belisarius Nov 6 '14 at 19:47
  • $\begingroup$ Duly edited. Thank you. $\endgroup$ – pgblu Nov 6 '14 at 19:50
Select[Split[Sort[Times @@@ Subsets[Prime@Range@PrimePi@100, {3}]], #2 == #1 + 1 &], 
      Length@# >= 3 &]

( {{1885, 1886, 1887}, {2013, 2014, 2015}} *)
| improve this answer | |
  • $\begingroup$ Aha, I THOUGHT there was something special about the year we live in! ;-) $\endgroup$ – pgblu Nov 6 '14 at 19:43
  • $\begingroup$ I recommend looking at those numbers which satisfy PrimeNu[#]==PrimeOmega[#]==3&. $\endgroup$ – Artes Nov 6 '14 at 19:57
  • $\begingroup$ @Artes I don't get you. The OP wants to generate numbers in the range {8, ... ,1999^3}. Obviously you're not proposing to check that range, so I don't understand how you would apply your comment. $\endgroup$ – Dr. belisarius Nov 6 '14 at 23:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.