|
|
A249919
|
|
Number of LCD (liquid-crystal display) segments needed to display n in binary.
|
|
1
|
|
|
6, 2, 8, 4, 14, 10, 10, 6, 20, 16, 16, 12, 16, 12, 12, 8, 26, 22, 22, 18, 22, 18, 18, 14, 22, 18, 18, 14, 18, 14, 14, 10, 32, 28, 28, 24, 28, 24, 24, 20, 28, 24, 24, 20, 24, 20, 20, 16, 28, 24, 24, 20, 24, 20, 20, 16, 24, 20, 20, 16, 20, 16, 16, 12, 38, 34, 34, 30, 34, 30, 30, 26, 34, 30, 30, 26, 30, 26, 26
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
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
|
|
|
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
|
(C)
// Input: n (no negative offset/term number), Output: a(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;
}
(Python)
x=bin(n)[2:]
s=0
for i in x:
s+=[6, 2][int(i)]
|
|
CROSSREFS
|
|
|
KEYWORD
|
easy,nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|