MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: compound symmetrical primes

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66509] Re: compound symmetrical primes
  • From: bghiggins at ucdavis.edu
  • Date: Wed, 17 May 2006 03:30:06 -0400 (EDT)
  • References: <e4birv$1a5$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

János,  Here is a fuction that tests for compoundness :

compoundPrimeQ := Module[{num = IntegerDigits[#]}, numLength =
Length[num];
      If[numLength == 1, False, Apply[Or, Union[Table[If[Apply[Plus,
Take[num,
       i]] - Apply[Plus, Take[num, -(numLength - i)]] == 0, True,
        False, False], {i, 1, numLength - 1}]]]]] &


Select[Prime[Range[1000]],compoundPrimeQ]

{11,101,167,211,257,347,431,523,541,617,743,761,853,1423,1427,1607,1753,1973,\
2011,2213,2237,2341,2417,2543,2617,2671,2819,2837,3137,3407,3461,3517,3571,\
3719,3847,4013,4127,4211,4217,4637,4673,4691,4729,4783,4967,5023,5113,5261,\
5519,5573,5591,5647,5683,5849,5867,6143,6217,6271,6473,6491,6529,6547,7043,\
7151,7331,7649,7759}

May not be as fast as yours though

Brian


  • Prev by Date: Re: Lists and rules
  • Next by Date: Re: Lists and rules
  • Previous by thread: Re: fixing contours
  • Next by thread: NonlinearFit problem