Concatenate list elements into a number in Mathematica -
i trying generate circular prime numbers in mathematica 8.
circular prime number number such rotations of digits prime
eg. 197 circular because 971, , 719, primal too.
now, in order test if prime number circular, generate rotations. follows:
p = integerdigits[197]; table[rotateleft[p, n], {n, length[p]}]
which consequently returns
{{9, 7, 1}, {7, 1, 9}, {1, 9, 7}}
however stuck. grab elements of each inner list , concatenate them in sequential order output becomes this
{971, 719, 197}
so can test if rotations satisfy primeq[].
while on 1 hand have done looping through list, seems me if there better way not realizing.
fromdigits
you're looking for.
fromdigits /@ {{9, 7, 1}, {7, 1, 9}, {1, 9, 7}} {971, 719, 197}
Comments
Post a Comment