Circular meaning all of its digit rotations are also prime.(adsbygoogle = window.adsbygoogle || []).push({}); Tried with this... Apparently I am wrong.Code (Text):PrimeLimit = 1000000;

NoRotate = Select[Range[PrimeLimit], PrimeQ];

Rotate1 =

Select[FromDigits[#] & /@ (RotateLeft[IntegerDigits[#]] & /@

Select[Range[PrimeLimit], PrimeQ]), PrimeQ];

Rotate2 =

Select[FromDigits[#] & /@ (RotateLeft[

RotateLeft[IntegerDigits[#]]] & /@

Select[Range[PrimeLimit], PrimeQ]), PrimeQ];

Rotate3 =

Select[FromDigits[#] & /@ (RotateLeft[

RotateLeft[RotateLeft[IntegerDigits[#]]]] & /@

Select[Range[PrimeLimit], PrimeQ]), PrimeQ];

Rotate4 =

Select[FromDigits[#] & /@ (RotateLeft[

RotateLeft[RotateLeft[RotateLeft[IntegerDigits[#]]]]] & /@

Select[Range[PrimeLimit], PrimeQ]), PrimeQ];

Rotate5 =

Select[FromDigits[#] & /@ (RotateLeft[

RotateLeft[

RotateLeft[RotateLeft[RotateLeft[IntegerDigits[#]]]]]] & /@

Select[Range[PrimeLimit], PrimeQ]), PrimeQ];

Count[Intersection[NoRotate, Rotate1, Rotate2, Rotate3, Rotate4,

Rotate5], _Integer]

I know it's ugly, but for the extent I'm familiar with mathematica, this was the fastest to write.

3 Relevant questions:

Why am I wrong?

How can I make it right?

How can I make it more streamlined/efficient/non-spaghettized?

Edit: Additional tinkering:This also fails :(Code (Text):PrimeLimit = 1000000;

PrimeList = Select[Range[PrimeLimit], PrimeQ];

For[i = 0, i < 5, i++,

PrimeList =

Intersection[PrimeList,

Select[FromDigits[#] & /@ (RotateLeft[IntegerDigits[#]] & /@

PrimeList), PrimeQ]]];

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# [Mathematica] How many circular primes below 1E+6

**Physics Forums | Science Articles, Homework Help, Discussion**