OFFSET
1,2
COMMENTS
Compute the prime factorization of n = product(p_i^r_i). If the tuple (r_1,...) is a palindrome (excluding leading or trailing zeros, but including any possible intermediate zeros), n belongs to the sequence.
42 is the first element of A242414 not in this sequence, as 42 = 2^1 * 3^1 * 5^0 * 7^1, and (1,1,0,1) is not a palindrome, although (1,1,1) is.
EXAMPLE
14 is a member as 14 = 2^1 * 3^0 * 5^0 * 7^1, and (1,0,0,1) is a palindrome.
42 is not a member as 42 = 2^1 * 3^1 * 5^0 * 7^1, and (1,1,0,1) is not a palindrome.
PROG
(Python)
import re
...
def factorize(n):
...for prime in primes:
......power = 0
......while n%prime==0:
.........n /= prime
.........power += 1
......yield power
...
re_zeros = re.compile('(?P<zeros>0*)(?P<middle>.*[^0])(?P=zeros)')
...
is_palindrome = lambda s: s==s[::-1]
...
def has_palindromic_factorization(n):
...if n==1:
......return True
...s = ''.join(str(x) for x in factorize(n))
...try:
......middle = re_zeros.match(s).group('middle')
......if is_palindrome(middle):
.........return True
...except AttributeError:
......return False
...
a = has_palindromic_factorization
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Christian Perfect, Jan 27 2014
STATUS
approved