1
$\begingroup$

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?

$\endgroup$
4
  • $\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$ Commented Nov 6, 2014 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
    Commented Nov 6, 2014 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$ Commented Nov 6, 2014 at 19:47
  • $\begingroup$ Duly edited. Thank you. $\endgroup$
    – pgblu
    Commented Nov 6, 2014 at 19:50

1 Answer 1

3
$\begingroup$
Select[Split[Sort[Times @@@ Subsets[Prime@Range@PrimePi@100, {3}]], #2 == #1 + 1 &], 
      Length@# >= 3 &]

( {{1885, 1886, 1887}, {2013, 2014, 2015}} *)
$\endgroup$
3
  • $\begingroup$ Aha, I THOUGHT there was something special about the year we live in! ;-) $\endgroup$
    – pgblu
    Commented Nov 6, 2014 at 19:43
  • $\begingroup$ I recommend looking at those numbers which satisfy PrimeNu[#]==PrimeOmega[#]==3&. $\endgroup$
    – Artes
    Commented Nov 6, 2014 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$ Commented Nov 6, 2014 at 23:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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