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.

A358509 Sum of decimal digits of (3^n - 1)/2 (A003462).

Original entry on oeis.org

0, 1, 4, 4, 4, 4, 13, 13, 13, 22, 22, 31, 22, 31, 31, 31, 22, 31, 31, 31, 31, 31, 49, 49, 40, 40, 49, 67, 58, 58, 58, 76, 58, 76, 85, 85, 85, 85, 94, 85, 85, 94, 103, 103, 85, 94, 103, 112, 103, 112, 130, 130, 94, 121, 112, 112, 121, 103, 103, 121, 112, 121, 121, 139, 121, 148, 121, 157, 157, 157, 157, 175, 157, 157
Offset: 0

Views

Author

Paul Curtz, Nov 20 2022

Keywords

Comments

a(n) == 4 (mod 9) for n >= 2. - Robert Israel, Nov 21 2022

Examples

			For n=5, (3^n - 1)/2 = 121 so that a(5) = 1+2+1 = 4.
		

Crossrefs

Cf. A004166 (of 3^n).

Programs

  • Maple
    seq(convert(convert((3^n-1)/2,base,10),`+`),n=0..100); # Robert Israel, Nov 21 2022
  • Mathematica
    a[n_] := Total[IntegerDigits[(3^n - 1)/2]]; Array[a, 100, 0] (* Amiram Eldar, Nov 20 2022 *)
  • PARI
    a(n) = sumdigits((3^n - 1)/2); \\ Michel Marcus, Nov 20 2022
    
  • Python
    def A358509(n): return sum(map(int,str((3**n-1)>>1))) # Chai Wah Wu, Nov 21 2022

Formula

a(n) = A007953(A003462(n)).