OFFSET
0,3
COMMENTS
a(n) == 4 (mod 9) for n >= 2. - Robert Israel, Nov 21 2022
LINKS
Michel Marcus, Table of n, a(n) for n = 0..5000
EXAMPLE
For n=5, (3^n - 1)/2 = 121 so that a(5) = 1+2+1 = 4.
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 *)
PROG
(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
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Paul Curtz, Nov 20 2022
STATUS
approved