cp's OEIS Frontend

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.

A383739 Smallest number that, when displayed on a 7-segment display using A006942, leaves exactly n segments unused.

This page as a plain text file.
%I A383739 #53 Jun 06 2025 18:06:36
%S A383739 8,0,2,4,7,1,10,12,14,17,11,101,112,114,117,111,1011,1112,1114,1117,
%T A383739 1111,10111,11112,11114,11117,11111,101111,111112,111114,111117,
%U A383739 111111,1011111,1111112,1111114,1111117,1111111,10111111,11111112,11111114,11111117,11111111,101111111
%N A383739 Smallest number that, when displayed on a 7-segment display using A006942, leaves exactly n segments unused.
%C A383739 6, 7, and 9 each have two possible representations on a 7-segment display. Therefore, a number that contains at least one of each digit can be displayed in 8 different ways. We use 'variant 5' because it was the first one added to the OEIS (A006942).
%C A383739 This sequence is interesting because a(n) is guaranteed to exist for n>=1. For instance, printing a '6' will always result in 1 unused segment. If we want to get a number that returns m unused segments, then we can always return '66...66' with '6' appearing m times. This also provides an upper bound for the value of a(n). Despite this, the value of a(n) for a given n is nontrivial.
%C A383739 This sequence does not increase monotonically.
%C A383739 Certain digits can never appear in the sequence for n>=1:
%C A383739 - 8: This digit contributes 0 unused segments. If a solution contains an 8 and has more than one digit, the 8 can be removed entirely without reducing the number of unused segments, resulting in a smaller number. The only exception is when the number is a single digit, so for a(0).
%C A383739 - 3 and 5: Both use the same number of segments as 2. So, if a solution includes a 3 or 5, we can replace it with a 2 without changing the number of unused segments, but the overall number would be smaller.
%C A383739 - 9: Same as above: any 9 can be replaced by a 6. We can't extend this to 0 (same number of segments as 6 or 9), because we can't always swap a 6 or a 9 for a 0 (e.g. '600').
%C A383739 Among all 10 digits, 1 has the largest number of unused segments (5). As a consequence, when n = 5*p (with p>=1), a(n) = '1..1' with 1 appearing p times because if a(n) contained any other digit, it would be more than p digits long, and would thus not be optimal.
%C A383739 The next term a(5*p+1) necessarily has an additional digit. The smallest digit that adds only 1 unused segment is 0 but it cannot be placed in the leading position. The next best position is the second one, thus a(5*p+1) = '10...1' with p 1s and a single 0.
%C A383739 To construct the next term a(5*p+2), we swap the existing zero for another digit with an additional unused segment (2 being optimal as it is the smallest) and move it to the trailing position (to yield the smallest possible number). Hence a(5*p+2) = '1..12' with p 1s and a single 2. Any other approach, such as adding an extra 0 or swapping a 1 for something else, would result in a solution with more than p+1 digits and would thus not be optimal.
%C A383739 The next two terms can be constructed the same way, yielding a(5*p+3) = '1..14' and a(5*p+4) = '1..17' with again p+1 digits in total. We then loop back to the beginning with a(5*p+5).
%H A383739 <a href="/index/Rec#order_10">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,0,0,11,0,0,0,0,-10).
%F A383739 For p>=1:
%F A383739 a(5*p) = (10^p-1)/9
%F A383739 a(5*p+1) = (91*10^(p-1)-1)/9
%F A383739 a(5*p+2) = (10^(p+1)-1)/9 + 1
%F A383739 a(5*p+3) = (10^(p+1)-1)/9 + 3
%F A383739 a(5*p+4) = (10^(p+1)-1)/9 + 6
%e A383739 a(1) is the smallest number with exactly 1 unused segment. The digit 0 uses 6 segments, leaving 1 unused, and since 0 is the smallest valid number, we have a(1) = 0.
%e A383739 For a(6), we seek the smallest number with exactly 6 unused segments. No single-digit number meets this, as each digit leaves at most 5 segments unused. Among two-digit numbers, 10 is the smallest: '1' contributes 5 unused segments and '0' contributes 1, totaling 6. Therefore, a(6) = 10.
%o A383739 (Python)
%o A383739 def a(n):
%o A383739     q, r = divmod(n, 5)
%o A383739     if q == 0:
%o A383739         return [8, 0, 2, 4, 7][r]
%o A383739     if r == 0:
%o A383739         return 10**q//9
%o A383739     if r == 1:
%o A383739         return 91*10**(q-1)//9
%o A383739     return 10**(q+1)//9 + [1, 3, 6][r - 2]
%Y A383739 Cf. A006942, A216261.
%K A383739 base,nonn,easy
%O A383739 0,1
%A A383739 _Renaud Gaudron_, May 12 2025