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.

Showing 1-9 of 9 results.

A006942 Number of segments used to represent n on calculator display, variant 5: digits '6', '7' and '9' use 6, 3 and 6 segments, respectively.

Original entry on oeis.org

6, 2, 5, 5, 4, 5, 6, 3, 7, 6, 8, 4, 7, 7, 6, 7, 8, 5, 9, 8, 11, 7, 10, 10, 9, 10, 11, 8, 12, 11, 11, 7, 10, 10, 9, 10, 11, 8, 12, 11, 10, 6, 9, 9, 8, 9, 10, 7, 11, 10, 11, 7, 10, 10, 9, 10, 11, 8, 12, 11, 12, 8, 11, 11, 10, 11, 12, 9, 13, 12, 9, 5, 8, 8, 7, 8, 9
Offset: 0

Views

Author

Keywords

Comments

a(A216261(n)) = n and a(m) <> n for m < A216261(n). - Reinhard Zumkeller, Mar 15 2013
If we mark with * resp. ' the graphical representations which use more resp. less segments, we have the following variants:
A063720 (6', 7', 9'), A277116 (6*, 7', 9'), A074458 (6*, 7*, 9'),
_____________ this: A006942 (6*, 7', 9*), A010371 (6*, 7*, 9*).
Sequences A234691, A234692 and variants make precise which segments are lit in each digit. These are related through the Hamming weight function A000120, e.g., A010371(n) = A000120(A234691(n)) = A000120(A234692(n)). - M. F. Hasler, Jun 17 2020

Examples

			As depicted below, zero uses 6 segments, so a(0)=6.
   _     _  _       _   _   _   _   _
  | | |  _| _| |_| |_  |_    | |_| |_|
  |_| | |_  _|   |  _| |_|   | |_|  _|
.
[Edited by _Jon E. Schoenfield_, Jul 30 2017]
		

References

  • Clifford A. Pickover, A Passion for Mathematics, Wiley, 2005; see p. 65.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A216261 (least inverse), A165244 (sorted digits), A302552 (primes), A328330 (iterations), A331529 (histogram).
Variants are A010371, A063720, A074458, A277116, see comments.
See also A234691, A234692, A000120.

Programs

  • Haskell
    a006942 n = a006942_list !! n
    a006942_list = [6,2,5,5,4,5,6,3,7,6] ++ f 10 where
       f x = (a006942 x' + a006942 d) : f (x + 1)
             where (x',d) = divMod x 10
    -- Reinhard Zumkeller, Mar 15 2013
    
  • Maple
    A006942 := proc(n) local d,dig,j,s: if(n=0)then return 6:fi: dig:=[6,2,5,5,4,5,6,3,7,6]: d:=convert(n,base,10): s:=0: for j from 1 to nops(d) do s:=s+dig[d[j]+1]: od: return s: end: seq(A006942(n),n=0..100); # Nathaniel Johnston, May 08 2011
  • Mathematica
    MapIndexed[ (f[First[#2] - 1] = #1)& , {6, 2, 5, 5, 4, 5, 6, 3, 7, 6}]; a[n_] := Plus @@ f /@ IntegerDigits[n]; Table[a[n], {n, 0, 76}] (* Jean-François Alcover, Sep 25 2012 *)
    a[n_] := Plus @@ (IntegerDigits@ n /. {0 -> 6, 1 -> 2, 2 -> 5, 3 -> 5, 7 -> 3, 8 -> 7, 9 -> 6}); Array[a, 77, 0] (* Robert G. Wilson v, Jun 20 2018 *)
  • PARI
    a(n)=if(n==0, return(6)); my(d=digits(n),v=vector(10)); for(i=1,#d, v[d[i]+1]++); v*[6, 2, 5, 5, 4, 5, 6, 3, 7, 6]~ \\ Charles R Greathouse IV, Feb 05 2018
    
  • Python
    def a(n): return sum([6, 2, 5, 5, 4, 5, 6, 3, 7, 6][int(d)] for d in str(n))
    print([a(n) for n in range(77)]) # Michael S. Branicky, Jun 02 2021

Formula

a(n) = a(floor(n/10)) + a(n mod 10) for n > 9. - Reinhard Zumkeller, Mar 15 2013
a(n) = A010371(n) - A102679(n) + A102681(n) (subtract the number of digits 7 in n) = A277116(n) + A102683(n) (add number of digits 9 in n); and in particular, A063720(n) <= A277116(n) <= a(n) = A010371(n). - M. F. Hasler, Jun 17 2020

Extensions

More terms from Matthew Conroy, Sep 13 2001

A331529 a(n) is the number of nonnegative integers that can be represented in a 7-segment display by using only n segments (version A006942).

Original entry on oeis.org

0, 0, 1, 1, 2, 5, 7, 12, 19, 33, 59, 99, 170, 290, 496, 854, 1463, 2506, 4292, 7351, 12601, 21596, 37005, 63405, 108637, 186154, 318989, 546600, 936606, 1604874, 2749973, 4712146, 8074374, 13835600, 23707533, 40623267, 69608738, 119275933, 204381606, 350211711, 600094277
Offset: 0

Views

Author

Stefano Spezia, Jan 19 2020

Keywords

Comments

The nonnegative integers are displayed as in A006942, where a 7 is depicted by 3 segments.
Given the set S = {2, 3, 4, 5, 6, 7}, the function f defined in S as f(5) = f(6) = 3 and f(s) = 1 elsewhere, a(n) is equal to the difference between the number b(n) of S-restricted f-weighted integer compositions of n with that of n-6, i.e., b(n-6). The latter one provides the number of all those excluded cases where a nonnegative integer is displayed with leading zeros. b(n) is calculated as the sum of polynomial coefficients or extended binomial coefficients (see Equation 3 in Eger) where the index of summation is positive and it covers the numbers of possible digits that can be displayed by n segments (see first formula).
The same sequence is obtained when 7 and 9 are depicted respectively by 4 and 5 segments (A074458). - Stefano Spezia, Apr 11 2021

Examples

			a(5) = 5 since 2, 3, 5, 17 and 71 are displayed by 5 segments.
   __      __       __         __      __
   __|     __|     |__       |   |       |  |
  |__      __|      __|      |   |       |  |
   (2)     (3)      (5)       (17)       (71)
		

Crossrefs

Programs

  • Mathematica
    P[x_]:=x^2+x^3+x^4+3x^5+3x^6+x^7; b[n_]:=Coefficient[Sum[P[x]^k,{k,Max[1,Ceiling[n/7]],Floor[n/2]}],x,n];a[n_]:=b[n]-b[n-6]; Array[a,41,0]
  • PARI
    concat([0,0], Vec(x^2*(1 - x)*(1 + x)^2*(1 - x + x^2)*(1 + x + x^2)*(1 + x^2 + 2*x^3 + x^4) / (1 - x^2 - x^3 - x^4 - 3*x^5 - 3*x^6 - x^7) + O(x^41))) \\ Colin Barker, Jan 20 2020

Formula

a(n) = b(n) - b(n-6), where b(n) = [x^n] Sum_{k=max(1,ceiling(n/7))..floor(n/2)} P(x)^k with P(x) = x^2 + x^3 + x^4 + 3*x^5 + 3*x^6 + x^7.
From Colin Barker, Jan 20 2020: (Start)
G.f.: x^2*(1 - x)*(1 + x)^2*(1 - x + x^2)*(1 + x + x^2)*(1 + x^2 + 2*x^3 + x^4) / (1 - x^2 - x^3 - x^4 - 3*x^5 - 3*x^6 - x^7).
a(n) = a(n-2) + a(n-3) + a(n-4) + 3*a(n-5) + 3*a(n-6) + a(n-7) for n>13.
(End)

A143617 Where record values occur in A010371.

Original entry on oeis.org

0, 8, 10, 18, 20, 28, 68, 88, 108, 188, 200, 208, 288, 688, 888, 1088, 1888, 2008, 2088, 2888, 6888, 8888, 10888, 18888, 20088, 20888, 28888, 68888, 88888, 108888, 188888, 200888, 208888, 288888, 688888, 888888, 1088888, 1888888, 2008888, 2088888
Offset: 1

Views

Author

Reinhard Zumkeller, Aug 27 2008

Keywords

Comments

a(n) is the least number using n + 6 (or n + 5 for n < 5) segments on a 7-segment display, when '6' uses 6 segments. This is essentially the same as A038619 (starts with 1, 2, 6 instead of 0) and A216261 (= a(n) uses n segments: has 4 values before 0 and 22 before 20). - M. F. Hasler, Jun 17 2020

Crossrefs

Programs

  • Mathematica
    Block[{f, s}, MapIndexed[(f[#2[[1]] - 1] = #1) &, {6, 2, 5, 5, 4, 5, 6, 4, 7, 6}]; s = Array[Total[f /@ IntegerDigits[#]] &, 10^6, 0]; Map[-1 + FirstPosition[s, #][[1]] &, Union@ FoldList[Max, s]]] (* Michael De Vlieger, Jun 23 2020 *)
  • PARI
    apply( {A143617(n)=if(n>11,self()(n-7)*10+8, n>9, 12*n+68, n>6, 20*n-72, n*5-2-n%2*3)}, [1..55]) \\ M. F. Hasler, Jun 23 2020

Formula

a(n+7) = 10*a(n) + 8 for n > 4.
A010371(a(n)) = A143616(n) and A010371(m) < A143616(n) for m < a(n).
A010371(a(n)) = n + 6 for n > 4. - M. F. Hasler, Jun 23 2020
a(n) = a(n-1) + 10*a(n-7) - 10*a(n-8). - Wesley Ivan Hurt, Jul 03 2020

A343314 a(n) is the number of nonnegative integers that can be represented in a 7-segment display by using only n segments (version A063720).

Original entry on oeis.org

0, 0, 1, 1, 2, 7, 5, 16, 19, 39, 77, 103, 226, 334, 636, 1106, 1827, 3386, 5568, 10059, 17281, 29890, 52771, 90283, 159191, 274976, 479035, 835476, 1447278, 2528496, 4386143, 7640592, 13293308, 23106132, 40245277, 69946521, 121762316, 211791205, 368418674, 641125867
Offset: 0

Views

Author

Stefano Spezia, Apr 11 2021

Keywords

Comments

The nonnegative integers are displayed as in A063720.
Given the set S = {2, 3, 4, 5, 6, 7}, the function f defined in S as f(5) = 5 and f(s) = 1 elsewhere, a(n) is equal to the difference between the number b(n) of S-restricted f-weighted integer compositions of n with that of n-6, i.e., b(n-6). The latter one provides the number of all those excluded cases where a nonnegative integer is displayed with leading zeros. b(n) is calculated as the sum of polynomial coefficients or extended binomial coefficients (see Equation 3 in Eger) where the index of summation is positive and it covers the numbers of possible digits that can be displayed by n segments (see third formula).

Examples

			a(6) = 5 since 0, 14, 41, 77 and 111 are displayed by 6 segments.
    __                                   __   __
   |  |      | |__|      |__|    |         |    |      |    |    |
   |__|      |    |         |    |         |    |      |    |    |
    (0)       (14)          (41)            (77)          (111)
		

Crossrefs

Programs

  • Mathematica
    P[x_]:=x^2+x^3+x^4+5x^5+x^6+x^7; b[n_]:=Coefficient[Sum[P[x]^k, {k, Max[1, Ceiling[n/7]], Floor[n/2]}], x, n]; a[n_]:=b[n]-b[n-6]; Array[a, 40, 0]

Formula

G.f.: x^2*(1 - x)*(1 + x)*(1 - x + x^2)*(1 + x + x^2)*(1 + x + x^2 + 5*x^3 + x^4 + x^5)/(1 - x^2 - x^3 - x^4 - 5*x^5 - x^6 - x^7).
a(n) = a(n-2) + a(n-3) + a(n-4) + 5*a(n-5) + a(n-6) + a(n-7) for n > 13.
a(n) = b(n) - b(n-6), where b(n) = [x^n] Sum_{k=max(1,ceiling(n/7))..floor(n/2)} P(x)^k with P(x) = x^2 + x^3 + x^4 + 5*x^5 + x^6 + x^7.

A343315 a(n) is the number of nonnegative integers that can be represented in a 7-segment display by using only n segments (version A277116).

Original entry on oeis.org

0, 0, 1, 1, 2, 6, 6, 14, 19, 36, 67, 103, 194, 315, 560, 971, 1651, 2895, 4933, 8581, 14798, 25515, 44165, 76067, 131563, 227034, 392032, 677152, 1168742, 2018769, 3485255, 6018422, 10392472, 17943750, 30985861, 53501944, 92385050, 159523542, 275451221, 475633952
Offset: 0

Views

Author

Stefano Spezia, Apr 11 2021

Keywords

Comments

The nonnegative integers are displayed as in A277116.
Given the set S = {2, 3, 4, 5, 6, 7}, the function f defined in S as f(5) = 4, f(6) = 2 and f(s) = 1 elsewhere, a(n) is equal to the difference between the number b(n) of S-restricted f-weighted integer compositions of n with that of n-6, i.e., b(n-6). The latter one provides the number of all those excluded cases where a nonnegative integer is displayed with leading zeros. b(n) is calculated as the sum of polynomial coefficients or extended binomial coefficients (see Equation 3 in Eger) where the index of summation is positive and it covers the numbers of possible digits that can be displayed by n segments (see third formula).

Examples

			a(5) = 6 since 2, 3, 5, 9, 17 and 71 are displayed by 5 segments.
   __        __        __        __          __       __
   __|       __|      |__       |__|      |    |        |    |
  |__        __|       __|         |      |    |        |    |
   (2)       (3)       (5)       (9)       (17)          (71)
		

Crossrefs

Programs

  • Mathematica
    P[x_]:=x^2+x^3+x^4+4x^5+2x^6+x^7; b[n_]:=Coefficient[Sum[P[x]^k, {k, Max[1, Ceiling[n/7]], Floor[n/2]}], x, n]; a[n_]:=b[n]-b[n-6]; Array[a, 40, 0]

Formula

G.f.: x^2*(1 - x)*(1 + x)*(1 - x + x^2)*(1 + x + x^2)*(1 + x + x^2 + 4*x^3 + 2*x^4 + x^5)/(1 - x^2 - x^3 - x^4 - 4*x^5 - 2*x^6 - x^7).
a(n) = a(n-2) + a(n-3) + a(n-4) + 4*a(n-5) + 2*a(n-6) + a(n-7) for n > 13.
a(n) = b(n) - b(n-6), where b(n) = [x^n] Sum_{k=max(1,ceiling(n/7))..floor(n/2)} P(x)^k with P(x) = x^2 + x^3 + x^4 + 4*x^5 + 2*x^6 + x^7.

A038619 Smallest positive number that needs more lines when shown on a 7-segment display (digital clock) than any previous term.

Original entry on oeis.org

1, 2, 6, 8, 10, 18, 20, 28, 68, 88, 108, 188, 200, 208, 288, 688, 888, 1088, 1888, 2008, 2088, 2888, 6888, 8888, 10888, 18888, 20088, 20888, 28888, 68888, 88888, 108888, 188888, 200888, 208888, 288888, 688888, 888888, 1088888, 1888888, 2008888, 2088888, 2888888, 6888888, 8888888
Offset: 1

Views

Author

Keywords

Comments

For n > 1, a(n) uses n + 3 segments to be displayed, when a digit '6' uses 6 segments (as in A234691, A234692 and A277116, A074458, A006942, A010371, but not in A063720). Sequence A143617 is the same but starts with 0, 8, ... and A216261 has additional terms 7 & 4 before 2 and 22 before 20. - M. F. Hasler, Jun 23 2020

Examples

			Digits 0, 1, 2, ..., 9 use 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 lines / segments.
		

Crossrefs

Programs

  • Mathematica
    Block[{f, s}, MapIndexed[(f[#2[[1]] - 1] = #1) &, {6, 2, 5, 5, 4, 5, 6, 3, 7, 6}]; s = Array[Total[f /@ IntegerDigits[#]] &, 10^7]; Map[FirstPosition[s, #][[1]] &, Union@ FoldList[Max, s]]] (* or *)
    Nest[Append[#1, If[#2 > 13, 10 #1[[-7]] + 8, 10 #1[[-6]] + Boole[#2 != 13] 8]] & @@ {#, Length@ # + 1} &, {1, 2, 6, 8, 10, 18, 20}, 36] (* Michael De Vlieger, Jun 23 2020 *)
    LinearRecurrence[{1,0,0,0,0,0,10,-10},{1,2,6,8,10,18,20,28,68,88,108,188,200,208},50] (* Harvey P. Dale, Aug 11 2025 *)
  • PARI
    apply( {A038619(n)=if(n>7, self()(n-6-(n>13))*10+(n!=13)*8, [1,2,6, 8,10,18,20][n])}, [1..33]) \\ M. F. Hasler, Jun 23 2020

Formula

For n >= 3, the terms with n digits are given by: 108*A + B, 188*A + B, 200*A + B, 208*A + B, 288*A + B, 688*A + B, 888*A + B where A = 10^(n-3), B = 8*(A - 1)/9.
From M. F. Hasler, Jun 23 2020: (Start)
a(n) = 10*a(n-7) + 8 for n > 13 (and with a(n-6) for 7 < n < 13).
G.f.: (1 + x + 4*x^2 + 2*x^3 + 2*x^4 + 8*x^5 + 2*x^6 - 2*x^7 + 30*x^8 - 20*x^9 + 60*x^11 - 68*x^12 - 12*x^13)/((1 - x)*(1 - x^10)).
(End)
a(n) = a(n-1) + 10*a(n-7) - 10*a(n-8), for n >= 15. - Wesley Ivan Hurt, Jun 29 2020

Extensions

Edited and offset corrected to 1 by M. F. Hasler, Jun 23 2020
More terms from Michael De Vlieger, Jun 23 2020
More terms from M. F. Hasler, Jun 23 2020

A337099 Largest positive number using exactly n segments on a calculator display (when '6' and '7' are represented using 6 resp. 3 segments).

Original entry on oeis.org

1, 7, 11, 71, 111, 711, 1111, 7111, 11111, 71111, 111111, 711111, 1111111, 7111111, 11111111, 71111111, 111111111, 711111111, 1111111111, 7111111111, 11111111111, 71111111111, 111111111111, 711111111111, 1111111111111, 7111111111111, 11111111111111, 71111111111111
Offset: 2

Views

Author

Suren Suren, Sep 29 2020

Keywords

Comments

The sequence begins with a(2) = 1 since at least two segments are needed to form any digit. It requires two segments to form the digit 1 and three segments to form the digit 7.
All other digits use more than 3 segments.

Crossrefs

Cf. A063720 (number of segments), A216261 (smallest number), A249572.

Programs

  • Mathematica
    CoefficientList[Series[(1 + 6*x - 6*x^2)/(1 - x - 10*x^2 + 10*x^3), {x, 0, 30}], x] (* Wesley Ivan Hurt, Nov 07 2020 *)

Formula

a(n+2) = 10*a(n) + 1 for n >= 2.
a(2*n) = (10^n - 1)/9 ; a(2*n + 1) = ((10^n - 1)/9) + 6*10^(n - 1).
From Stefano Spezia, Sep 29 2020: (Start)
G.f.: x^2*(1 + 6*x - 6*x^2)/(1 - x - 10*x^2 + 10*x^3).
a(n) = a(n-1) + 10*a(n-2) - 10*a(n-3) for n > 4. (End)

Extensions

More terms from Stefano Spezia, Sep 29 2020

A339700 a(n) is the n-th nonnegative number to light exactly n segments when displayed on a calculator.

Original entry on oeis.org

71, 77, 47, 61, 70, 52, 62, 99, 136, 190, 246, 263, 306, 589, 882, 1085, 1838, 2059, 2308, 2869, 5886, 8689, 10800, 18098, 20268, 20896, 28608, 58880, 86886, 106898, 180889, 200858, 208698, 283888, 588868, 868880, 1068889, 1808886, 2008086, 2086868, 2809888, 5888808, 8688868, 10688886, 18088880
Offset: 5

Views

Author

Graham Holmes, Dec 13 2020

Keywords

Comments

a(n) is undefined for n<5, as there are no numbers with 1 segment, 1 with 2 segments, 1 with 3 segments, and 2 with 4 segments. If 0 is excluded as a valid input - so the series would refer to "the n-th positive number" - then a(6) would be 111 rather than 77.

Examples

			For n=7, 47 is the 7th positive number to light 7 segments, after 8, 12, 13, 15, 21, and 31.
		

Crossrefs

Cf. A006942 (segments lit), A216261, A331529.

Programs

  • JavaScript
    s=[6,2,5,5,4,5,6,3,7,6];p=[];a=[];for(i=2;i<=100;i++)p[i]=0;for(i=1;i<=1000000;i++){d=i;n=0;do{x=d%10;n+=s[x];d=(d-x)/10;}while(d>0)p[n]++;if(p[n]==n)a[n]=i;}for(c=2;c<=40;c++)document.write(c+": "+a[c]+"
    ");

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

Original entry on oeis.org

8, 0, 2, 4, 7, 1, 10, 12, 14, 17, 11, 101, 112, 114, 117, 111, 1011, 1112, 1114, 1117, 1111, 10111, 11112, 11114, 11117, 11111, 101111, 111112, 111114, 111117, 111111, 1011111, 1111112, 1111114, 1111117, 1111111, 10111111, 11111112, 11111114, 11111117, 11111111, 101111111
Offset: 0

Views

Author

Renaud Gaudron, May 12 2025

Keywords

Comments

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).
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.
This sequence does not increase monotonically.
Certain digits can never appear in the sequence for n>=1:
- 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).
- 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.
- 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').
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.
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.
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.
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).

Examples

			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.
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.
		

Crossrefs

Programs

  • Python
    def a(n):
        q, r = divmod(n, 5)
        if q == 0:
            return [8, 0, 2, 4, 7][r]
        if r == 0:
            return 10**q//9
        if r == 1:
            return 91*10**(q-1)//9
        return 10**(q+1)//9 + [1, 3, 6][r - 2]

Formula

For p>=1:
a(5*p) = (10^p-1)/9
a(5*p+1) = (91*10^(p-1)-1)/9
a(5*p+2) = (10^(p+1)-1)/9 + 1
a(5*p+3) = (10^(p+1)-1)/9 + 3
a(5*p+4) = (10^(p+1)-1)/9 + 6
Showing 1-9 of 9 results.