Combining list items into numbers in Mathematica

I am trying to create circular primes in Mathematica 8.
A circular prime is a number such that all rotations of its digits are primary

Eg. 197 is circular because 971 and 719 are also primary.

Now, to check if the prime is circular, I generate all the rotations. I do it as follows:

p = IntegerDigits[197]; Table[RotateLeft[p, n], {n, Length[p]}] 

Which therefore returns

 {{9, 7, 1}, {7, 1, 9}, {1, 9, 7}} 

However, it is here that I am stuck. Now I would like to grab the elements of each internal list and combine them in sequential order so that the output becomes this

 {971, 719, 197} 

So that I can check if all the PrimeQ [] turns satisfy.

Although I, on the one hand, could do this by going through the list, it seems to me that there is a better way that I simply do not understand.

+4
source share
1 answer

FromDigits is what you are looking for.

 FromDigits /@ {{9, 7, 1}, {7, 1, 9}, {1, 9, 7}} {971, 719, 197} 
+6
source

All Articles