login
Sum of digits of n if n even, else sum of digits of 2n.
2

%I #9 Mar 18 2019 16:27:39

%S 0,2,2,6,4,1,6,5,8,9,1,4,3,8,5,3,7,7,9,11,2,6,4,10,6,5,8,9,10,13,3,8,

%T 5,12,7,7,9,11,11,15,4,10,6,14,8,9,10,13,12,17,5,3,7,7,9,2,11,6,13,10,

%U 6,5,8,9,10,4,12,8,14,12,7,7,9,11,11,6,13,10,15,14,8,9,10,13,12,8,14,12,16

%N Sum of digits of n if n even, else sum of digits of 2n.

%C Inspired by Luhn algorithm for validating credit cards.

%F a(n) = sum of digits(if even n then n else 2n).

%e a(11) = 4 = 2 + 2 (2 and 2 are the digits in 22 = 2 * 11).

%e a(12) = 3 = 1 + 2 (1 and 2 are the digits in 12).

%t f[n_] := Plus @@ IntegerDigits[ If[ EvenQ[n], n, 2n]]; Table[ f[n], {n, 0, 90}] (* _Robert G. Wilson v_, Mar 24 2004 *)

%t Table[If[EvenQ[n],Total[IntegerDigits[n]],Total[IntegerDigits[2n]]],{n,0,120}] (* _Harvey P. Dale_, Mar 18 2019 *)

%Y Cf. A092383, A093150.

%K easy,nonn,base

%O 0,2

%A Semaphore Corporation (help(AT)semaphorecorp.com), Mar 20 2004

%E Corrected and extended by _Ray Chandler_, Mar 21 2004