Re: compound symmetrical primes
- To: mathgroup at smc.vnet.net
- Subject: [mg66503] Re: compound symmetrical primes
- From: Peter Pein <petsie at dordos.net>
- Date: Wed, 17 May 2006 03:29:48 -0400 (EDT)
- References: <e4birv$1a5$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
János schrieb:
> Let's say that a prime is symmetrical if prime==FromDigits[Reverse
> [IntegerDigits[prime]]].
>
> I would say a prime is compound if two contiguous distinct subsets of
> its digits are summing up to the same number. For example 211 is a
> compound prime because 2=1+1. Similarly 15877 is a compound prime
> because 1+5+8=7+7. May be there is a better definition in the prime
> literature. The two distinct subset has to cover all the digits.
>
> Here is a little program that that looks for symmetrical compound
> primes up to an mx limit.
>
> In[14]:=
> lst = Timing[First[
> Last[Reap[i = 1;
> mx = 10^6; While[
> i <= mx,
> pr = Prime[i];
> If[pr != FromDigits[
> Reverse[
> IntegerDigits[
> pr]]], i++;
> Continue[]; ];
> prdig =
> IntegerDigits[pr];
> prlen = Length[
> prdig]; j = 1;
> While[j < prlen,
> prLeft = Take[
> prdig, {1, j}];
> prRight = Take[
> prdig, {j + 1,
> prlen}];
> If[Total[prLeft] !=
> Total[prRight],
> j++; Continue[],
> Sow[pr]; Break[
> ]]; ]; i++; ]; ]]]]
> Out[14]=
> {31.687534999999997*Second,
> {11, 101, 16061, 31013,
> 35053, 38083, 73037,
> 74047, 91019, 94049,
> 1120211, 1150511, 1160611,
> 1180811, 1190911, 1250521,
> 1280821, 1300031, 1360631,
> 1390931, 1490941, 1520251,
> 1550551, 1580851, 1600061,
> 1630361, 1640461, 1660661,
> 1670761, 1730371, 1820281,
> 1880881, 1930391, 1970791,
> 3140413, 3160613, 3260623,
> 3310133, 3380833, 3400043,
> 3460643, 3470743, 3590953,
> 3670763, 3680863, 3970793,
> 7100017, 7190917, 7250527,
> 7300037, 7310137, 7540457,
> 7600067, 7630367, 7690967,
> 7750577, 7820287, 7850587,
> 7930397, 7960697, 9110119,
> 9200029, 9230329, 9280829,
> 9320239, 9400049, 9440449,
> 9470749, 9610169, 9620269,
> 9650569, 9670769, 9700079,
> 9770779, 9820289, 9980899}}
>
> Here are a few questions:
>
> Is there any compound symmetrical prime other than 11 whose length is
> even ?
No, they are divisible by 11.
>
> Is there any compound symmetrical prime where the middle digit is not
> zero ?
No, since the subsets of the digits have to be contigous, the middle digit has to be zero.
>
> Is there a much faster algorithm to find these numbers ? /I am
> mostly procedural here :) because I could not find a functional check
> for compoundness. /
> I searched up to mx=10^8 and on my little iBook it took the whole night.
This finds the "constructors" of all the compound symmetrical primes up to 10^(2*6-1):
{t,mylst2}=Timing@Select[Range[10^6],
Function[tst,
Module[{pr=Join[#,Piecewise[{{#,Length[#]==1}},Rest@Reverse[#]]]&@
IntegerDigits[tst],n},
n=FromDigits[pr];
PrimeQ[n]&&
MemberQ[Tr/@Through[{Take,Drop}[pr,#]]&/@Range[Length[pr]],
{x_Integer,x_}]
]]];
t
--> 57.375 Second
(your original code needs 18.766 to run on my computer)
Length[mylst2]
--> 4462
>
> Let's say a number is periodical if it is a repetition of a subset of
> its digits . For example 11 and 232323 are periodic numbers.
>
> Is 11 the only periodical symmetrical compound prime ?
Every other periodical number is divisible by Sum[10^(k*p),k=0..n-1], p=length of the period, and n the count of repetitions of the period.
>
> Thanks ahead,
>
> János
>
You're welcome :-)
Peter