OFFSET
0,1
COMMENTS
The "LCD" refers to how 0 and 1 are displayed, such that zero is represented with 6 lines, and one is represented with 2 lines:
_
| | |
|_| and |
LINKS
Indranil Ghosh, Table of n, a(n) for n = 0..32768
FORMULA
The formulas below do not include a(0)=6:
a(2^(n-1)) = 2 + 6(n-1).
a((2^n)-1) = 2n.
a(x) = a(2^(n+1) + (2^n)-1) = a(2^(n+2)-1) + 4.
a(y) = a(2^(n+1) + (2^n)) = a(2^(n+1)) - 4.
a(x - u) + 6 = a(x - u + 2^(n+1)).
a(y + u) + 6 = a(y + u + 2^(n+1)).
a(2^(n+1)) + a(2^(n+2)-1) = a(x - u) + a(y + u).
where n=1, 2, ...
and u=0, ..., (2^n)-2.
EXAMPLE
For n = 4, 4 = 100_2. So, a(4) = 2 + 6 + 6 = 14. - Indranil Ghosh, Feb 02 2017
MATHEMATICA
f[n_] := Total[{2, 6}*(Count[ IntegerDigits[n, 2], #] & /@ {1, 0})]; Array[f, 79, 0] (* Robert G. Wilson v, Jul 26 2015 *)
PROG
(PARI) a(n)=if(n==0, 6, 6*#binary(n) - 4*hammingweight(n)); \\ Charles R Greathouse IV, Feb 28 2015
(C)
// Input: n (no negative offset/term number), Output: a(n)
int A249919 (int n) {
int m=0, r=0;
if (n) {
while (n!=1) {
m=n&1; //equivalent to m=n%2;
n=n>>1; //equivalent to n/=2;
if (m) {
r+=2;
} else {
r+=6;
}
}
r+=2;
} else {
r+=6;
}
return r;
}
// Arlu Genesis A. Padilla, Jun 18 2015
(Python)
def A249919(n):
x=bin(n)[2:]
s=0
for i in x:
s+=[6, 2][int(i)]
return s # Indranil Ghosh, Feb 02 2017
CROSSREFS
KEYWORD
easy,nonn,base
AUTHOR
Arlu Genesis A. Padilla, Jan 14 2015
STATUS
approved