This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A249919 #43 Jun 24 2022 19:55:17 %S A249919 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, %T A249919 18,18,14,18,14,14,10,32,28,28,24,28,24,24,20,28,24,24,20,24,20,20,16, %U A249919 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 %N A249919 Number of LCD (liquid-crystal display) segments needed to display n in binary. %C A249919 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: %C A249919 _ %C A249919 | | | %C A249919 |_| and | %H A249919 Indranil Ghosh, <a href="/A249919/b249919.txt">Table of n, a(n) for n = 0..32768</a> %F A249919 The formulas below do not include a(0)=6: %F A249919 a(2^(n-1)) = 2 + 6(n-1). %F A249919 a((2^n)-1) = 2n. %F A249919 a(x) = a(2^(n+1) + (2^n)-1) = a(2^(n+2)-1) + 4. %F A249919 a(y) = a(2^(n+1) + (2^n)) = a(2^(n+1)) - 4. %F A249919 a(x - u) + 6 = a(x - u + 2^(n+1)). %F A249919 a(y + u) + 6 = a(y + u + 2^(n+1)). %F A249919 a(2^(n+1)) + a(2^(n+2)-1) = a(x - u) + a(y + u). %F A249919 where n=1, 2, ... %F A249919 and u=0, ..., (2^n)-2. %F A249919 a(n) = A010371(A007088(n)). - _Michel Marcus_, Aug 01 2015 %e A249919 For n = 4, 4 = 100_2. So, a(4) = 2 + 6 + 6 = 14. - _Indranil Ghosh_, Feb 02 2017 %t A249919 f[n_] := Total[{2, 6}*(Count[ IntegerDigits[n, 2], #] & /@ {1, 0})]; Array[f, 79, 0] (* _Robert G. Wilson v_, Jul 26 2015 *) %o A249919 (PARI) a(n)=if(n==0, 6, 6*#binary(n) - 4*hammingweight(n)); \\ _Charles R Greathouse IV_, Feb 28 2015 %o A249919 (C) %o A249919 // Input: n (no negative offset/term number), Output: a(n) %o A249919 int A249919 (int n) { %o A249919 int m=0, r=0; %o A249919 if (n) { %o A249919 while (n!=1) { %o A249919 m=n&1; //equivalent to m=n%2; %o A249919 n=n>>1; //equivalent to n/=2; %o A249919 if (m) { %o A249919 r+=2; %o A249919 } else { %o A249919 r+=6; %o A249919 } %o A249919 } %o A249919 r+=2; %o A249919 } else { %o A249919 r+=6; %o A249919 } %o A249919 return r; %o A249919 } %o A249919 // _Arlu Genesis A. Padilla_, Jun 18 2015 %o A249919 (Python) %o A249919 def A249919(n): %o A249919 x=bin(n)[2:] %o A249919 s=0 %o A249919 for i in x: %o A249919 s+=[6,2][int(i)] %o A249919 return s # _Indranil Ghosh_, Feb 02 2017 %Y A249919 Cf. A007088, A010371, A074458. %K A249919 easy,nonn,base %O A249919 0,1 %A A249919 _Arlu Genesis A. Padilla_, Jan 14 2015