A236510 Numbers whose prime factorization viewed as a tuple of powers is palindromic, when viewed from the least to the largest prime present, including also any zero-exponents for the intermediate primes.
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 19, 21, 22, 23, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 43, 46, 47, 49, 51, 53, 55, 57, 58, 59, 61, 62, 64, 65, 67, 69, 71, 73, 74, 77, 79, 81, 82, 83, 85, 86, 87, 89, 90, 91, 93, 94, 95
Offset: 1
Examples
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.
Programs
-
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
0*)(?P .*[^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
Comments