login
Derivative of n in base 3.
1

%I #23 Nov 01 2024 15:07:51

%S 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,

%T 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,

%U 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

%N Derivative of n in base 3.

%H Reinhard Zumkeller, <a href="/A038555/b038555.txt">Table of n, a(n) for n = 0..10000</a>

%F Write n in ternary, replace each pair of adjacent digits by their modulo 3 sum.

%e 15 = 120 in ternary, derivative is 02 = 2, so a(15)=2.

%t Table[FromDigits[Mod[Total[#],3]&/@Partition[IntegerDigits[n,3],2,1],3],{n,0,100}] (* _Harvey P. Dale_, Nov 01 2024 *)

%o (Haskell)

%o a038555 n = foldr (\d v -> v * 3 + d) 0 $

%o zipWith (\x y -> (x + y) `mod` 3) ts $ tail ts

%o where ts = a030341_row n

%o -- _Reinhard Zumkeller_, May 26 2013

%o (J) ab3 =: 3&#.^:_1

%o sp =: 2&(+/\)"1

%o > (3 | sp)&.ab3&.> ;/ i. 100 NB. _Stephen Makdisi_, May 26 2018

%Y Cf. A038554.

%Y Cf. A030341.

%K nonn,nice,easy,base

%O 0,5

%A _N. J. A. Sloane_

%E More terms from _Erich Friedman_

%E Formula corrected by _Reinhard Zumkeller_, May 26 2013