cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A043262 Sum of digits of n-th base 3 palindrome.

This page as a plain text file.
%I A043262 #11 Jul 25 2024 02:49:20
%S A043262 0,1,2,2,4,2,3,4,4,5,6,2,4,6,4,6,8,2,3,4,4,5,6,6,7,8,4,5,6,6,7,8,8,9,
%T A043262 10,2,4,6,4,6,8,6,8,10,4,6,8,6,8,10,8,10,12,2,3,4,4,5,6,6,7,8,4,5,6,6,
%U A043262 7,8,8,9,10,6,7,8,8,9,10,10,11,12,4,5,6,6,7,8
%N A043262 Sum of digits of n-th base 3 palindrome.
%t A043262 Total/@Select[IntegerDigits[Range[0,2000],3],#==Reverse[#]&] (* _Harvey P. Dale_, Aug 08 2019 *)
%o A043262 (Python)
%o A043262 from gmpy2 import digits
%o A043262 def A043262(n):
%o A043262     if n == 1: return 0
%o A043262     y = 3*(x:=3**(len(digits(n>>1, 3))-1))
%o A043262     return int((s:=digits(n-x,3))[-1])+(sum(int(d) for d in s[:-1])<<1) if n<x+y else sum(map(int,digits(n-y,3)))<<1 # _Chai Wah Wu_, Jul 24 2024
%Y A043262 Cf. A014190 (base 3 palindromes)
%K A043262 nonn,base
%O A043262 1,3
%A A043262 _Clark Kimberling_