login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A308832 Numbers that are palindromic in bases 3, 9 and 27. 1
0, 1, 2, 4, 8, 10, 20, 364, 728, 730, 1460, 2920, 5840, 7300, 7381, 7462, 14600, 14681, 14762, 265720, 531440, 531442, 532171, 532900, 1062884, 1063613, 1064342, 2125768, 2128684, 2131600, 4251536, 4254452, 4257368, 5314420, 5321710, 5329000, 5373550, 5380840, 5388130, 5432680, 5439970, 5447260 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,3
COMMENTS
This sequence is infinite because it contains terms of the forms 729^k-1 (k>=0) and 729^k+1 (k>=0).
Let L_27 be the number of digits for a(n) represented in base 27.
If L_27 is odd, the digits are either in the set {0, 1, 2} or in {0, 4, 8} or in {0, 10_10, 20_10}.
If L_27 is even, the digits are either in the set {0, 13_10} or in {0, 26_10} or in {13_10, 26_10}.
Let L_3 be the length of a(n) if represented in base 3, then L_3 in {0,1,2,3} (mod 6).
LINKS
MATHEMATICA
palQ[n_, b_] := PalindromeQ[IntegerDigits[n, b]]; aQ[n_] := AllTrue[{3, 9, 27}, palQ[n, #] &]; Select[Range[0, 6*10^6], aQ] (* Amiram Eldar, Jul 04 2019 *)
PROG
(Python)
def nextpal(n, base): # m is the first palindrome successor of n in base base
m, pl = n+1, 0
while m > 0:
m, pl = m//base, pl+1
if n+1 == base**pl:
pl = pl+1
n = n//(base**(pl//2))+1
m, n = n, n//(base**(pl%2))
while n > 0:
m, n = m*base+n%base, n//base
return m
def rev(n, b):
m = 0
while n > 0:
n, m = n//b, m*b+n%b
return m
n, a = 1, 0
while n <= 20000:
if a == rev(a, 9) and a == rev(a, 3):
print(n, a)
n = n+1
a = nextpal(a, 27)
(PARI) nextpal(n, b) = {my(m=n+1, p = 0); while (m > 0, m = m\b; p++; ); if (n+1 == b^p, p++); n = n\(b^(p\2))+1; m = n; n = n\(b^(p%2)); while (n > 0, m = m*b + n%b; n = n\b; ); m; } \\ after Python
ispal(n, b) = my(d=digits(n, b)); Vecrev(d) == d;
lista(nn) = {my(k=0); while (k <= nn, if (ispal(k, 3) && ispal(k, 9), print1(k, ", "); ); k = nextpal(k, 27); ); } \\ Michel Marcus, Jul 04 2019
CROSSREFS
Subsequence of A259386.
Cf. A319584 (palindromic in bases 2, 4 and 8).
Sequence in context: A259386 A004655 A127101 * A124849 A056654 A365002
KEYWORD
nonn,base
AUTHOR
A.H.M. Smeets, Jun 27 2019
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 21:09 EDT 2024. Contains 371798 sequences. (Running on oeis4.)