A038555 Derivative of n in base 3.
0, 0, 0, 1, 2, 0, 2, 0, 1, 3, 4, 5, 7, 8, 6, 2, 0, 1, 6, 7, 8, 1, 2, 0, 5, 3, 4, 9, 10, 11, 13, 14, 12, 17, 15, 16, 21, 22, 23, 25, 26, 24, 20, 18, 19, 6, 7, 8, 1, 2, 0, 5, 3, 4, 18, 19, 20, 22, 23, 21, 26, 24, 25, 3, 4, 5, 7, 8, 6, 2, 0, 1, 15, 16, 17, 10, 11, 9, 14, 12, 13, 27, 28, 29
Offset: 0
Examples
15 = 120 in ternary, derivative is 02 = 2, so a(15)=2.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
Programs
-
Haskell
a038555 n = foldr (\d v -> v * 3 + d) 0 $ zipWith (\x y -> (x + y) `mod` 3) ts $ tail ts where ts = a030341_row n -- Reinhard Zumkeller, May 26 2013
-
J
ab3 =: 3.^:_1 sp =: 2&(+/\)"1 > (3 | sp)&.ab3&.> ;/ i. 100 NB. Stephen Makdisi, May 26 2018
-
Mathematica
Table[FromDigits[Mod[Total[#],3]&/@Partition[IntegerDigits[n,3],2,1],3],{n,0,100}] (* Harvey P. Dale, Nov 01 2024 *)
Formula
Write n in ternary, replace each pair of adjacent digits by their modulo 3 sum.
Extensions
More terms from Erich Friedman
Formula corrected by Reinhard Zumkeller, May 26 2013