- #1
martix
- 168
- 4
Circular meaning all of its digit rotations are also prime.
Tried with this... Apparently I am wrong.
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:
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:
Code:
PrimeLimit = 1000000;
PrimeList = Select[Range[PrimeLimit], PrimeQ];
For[i = 0, i < 5, i++,
PrimeList =
Intersection[PrimeList,
Select[FromDigits[#] & /@ (RotateLeft[IntegerDigits[#]] & /@
PrimeList), PrimeQ]]];
Last edited: