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-10 of 30 results. Next

A035327 Write n in binary, interchange 0's and 1's, convert back to decimal.

Original entry on oeis.org

1, 0, 1, 0, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46
Offset: 0

Views

Author

Keywords

Comments

For n>0: largest m<=n such that no carry occurs when adding m to n in binary arithmetic: A003817(n+1) = a(n) + n = a(n) XOR n. - Reinhard Zumkeller, Nov 14 2009
a(0) could be considered to be 0 (it was set so from 2004 to 2008) if the binary representation of zero was chosen to be the empty string. - Jason Kimberley, Sep 19 2011
For n > 0: A240857(n,a(n)) = 0. - Reinhard Zumkeller, Apr 14 2014
This is a base-2 analog of A048379. Another variant, without converting back to decimal, is given in A256078. - M. F. Hasler, Mar 22 2015
For n >= 2, a(n) is the least nonnegative k that must be added to n+1 to make a power of 2. Hence in a single-elimination tennis tournament with n entrants, a(n-1) is the number of players given a bye in round one, so that the number of players remaining at the start of round two is a power of 2. For example, if 39 players register, a(38)=25 players receive a round-one bye leaving 14 to play, so that round two will have 25+(14/2)=32 players. - Mathew Englander, Jan 20 2024

Examples

			8 = 1000 -> 0111 = 111 = 7.
		

Crossrefs

a(n) = A003817(n) - n, for n>0.
Cf. A240857.

Programs

  • Haskell
    a035327 n = if n <= 1 then 1 - n else 2 * a035327 n' + 1 - b
                where (n',b) = divMod n 2
    -- Reinhard Zumkeller, Feb 21 2014
    
  • Julia
    using IntegerSequences
    A035327List(len) = [Bits("NAND", n, n) for n in 0:len]
    println(A035327List(100))  # Peter Luschny, Sep 25 2021
  • Magma
    A035327:=func; // Jason Kimberley, Sep 19 2011
    
  • Maple
    seq(2^(1 + ilog2(max(n, 1))) - 1 - n, n = 0..81); # Emeric Deutsch, Oct 19 2008
    A035327 := n -> `if`(n=0, 1, Bits:-Nand(n, n)):
    seq(A035327(n), n=0..81); # Peter Luschny, Sep 23 2019
  • Mathematica
    Table[BaseForm[FromDigits[(IntegerDigits[i, 2]/.{0->1, 1->0}), 2], 10], {i, 0, 90}]
    Table[BitXor[n, 2^IntegerPart[Log[2, n] + 1] - 1], {n, 100}] (* Alonso del Arte, Jan 14 2006 *)
    Join[{1},Table[2^BitLength[n]-n-1,{n,100}]] (* Paolo Xausa, Oct 13 2023 *)
    Table[FromDigits[IntegerDigits[n,2]/.{0->1,1->0},2],{n,0,90}] (* Harvey P. Dale, May 03 2025 *)
  • PARI
    a(n)=sum(k=1,n,if(bitxor(n,k)>n,1,0)) \\ Paul D. Hanna, Jan 21 2006
    
  • PARI
    a(n) = bitxor(n, 2^(1+logint(max(n,1), 2))-1) \\ Rémy Sigrist, Jan 04 2019
    
  • PARI
    a(n)=if(n, bitneg(n, exponent(n)+1), 1) \\ Charles R Greathouse IV, Apr 13 2020
    
  • Python
    def a(n): return int(''.join('1' if i == '0' else '0' for i in bin(n)[2:]), 2) # Indranil Ghosh, Apr 29 2017
    
  • Python
    def a(n): return 1 if n == 0 else n^((1 << n.bit_length()) - 1)
    print([a(n) for n in range(100)]) # Michael S. Branicky, Sep 28 2021
    
  • Python
    def A035327(n): return (~n)^(-1<Chai Wah Wu, Dec 20 2022
    
  • SageMath
    def a(n):
        if n == 0:
            return 1
        return sum([(1 - b) << s for (s, b) in enumerate(n.bits())])
    [a(n) for n in srange(82)]  # Peter Luschny, Aug 31 2019
    

Formula

a(n) = 2^k - n - 1, where 2^(k-1) <= n < 2^k.
a(n+1) = (a(n)+n) mod (n+1); a(0) = 1. - Reinhard Zumkeller, Jul 22 2002
G.f.: 1 + 1/(1-x)*Sum_{k>=0} 2^k*x^2^(k+1)/(1+x^2^k). - Ralf Stephan, May 06 2003
a(0) = 0, a(2n+1) = 2*a(n), a(2n) = 2*a(n) + 1. - Philippe Deléham, Feb 29 2004
a(n) = number of positive integers k < n such that n XOR k > n. a(n) = n - A006257(n). - Paul D. Hanna, Jan 21 2006
a(n) = 2^{1+floor(log[2](n))}-n-1 for n>=1; a(0)=1. - Emeric Deutsch, Oct 19 2008
a(n) = if n<2 then 1 - n else 2*a(floor(n/2)) + 1 - n mod 2. - Reinhard Zumkeller, Jan 20 2010
a(n) = abs(2*A053644(n) - n - 1). - Mathew Englander, Jan 22 2024

Extensions

More terms from Vit Planocka (planocka(AT)mistral.cz), Feb 01 2003
a(0) corrected by Paolo P. Lava, Oct 22 2007
Definition completed by M. F. Hasler, Mar 22 2015

A054054 Smallest digit of n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 0, 1, 2, 3, 4, 5, 5, 5, 5, 5, 0, 1, 2, 3, 4, 5, 6, 6, 6, 6, 0, 1, 2, 3, 4, 5, 6, 7, 7, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0
Offset: 0

Views

Author

Henry Bottomley, Apr 29 2000

Keywords

Comments

a(n) = 0 for almost all n. - Charles R Greathouse IV, Oct 02 2013
More precisely, a(n) = 0 asymptotically almost surely, i.e., except for a set of density 0: As the number of digits of n grows, the probability of having no zero digit goes to zero as 0.9^(length of n), although there are infinitely many counterexamples. - M. F. Hasler, Oct 11 2015

Examples

			a(12) = 1 because 1 < 2.
		

Crossrefs

Programs

  • Haskell
    a054054 = f 9 where
       f m x | x <= 9 = min m x
             | otherwise = f (min m d) x' where (x',d) = divMod x 10
    -- Reinhard Zumkeller, Jun 20 2012, Apr 25 2012
    
  • Maple
    seq(min(convert(n,base,10)),n=0..100); # Robert Israel, Jul 07 2016
  • Mathematica
    A054054[n_]:=Min[IntegerDigits[n]]
  • PARI
    A054054(n)=if(n,vecmin(digits(n)))  \\ or: Set(digits(n))[1]. - M. F. Hasler, Jan 23 2013

Formula

a(A011540(n)) = 0; a(A052382(n)) > 0. - Reinhard Zumkeller, Apr 25 2012
a(n) = A262188(n,0). - Reinhard Zumkeller, Sep 14 2015
a(n) = 0 iff A007954(n) = 0. - M. F. Hasler, Oct 11 2015
a(n) = 9 - A054055(A061601(n)). - Robert Israel, Jul 07 2016

Extensions

Edited by M. F. Hasler, Oct 11 2015

A055120 Digital complement of n (replace each nonzero digit d with 10-d).

Original entry on oeis.org

0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 90, 99, 98, 97, 96, 95, 94, 93, 92, 91, 80, 89, 88, 87, 86, 85, 84, 83, 82, 81, 70, 79, 78, 77, 76, 75, 74, 73, 72, 71, 60, 69, 68, 67, 66, 65, 64, 63, 62, 61, 50, 59, 58, 57, 56, 55, 54, 53, 52, 51, 40, 49, 48, 47, 46, 45, 44, 43, 42, 41, 30, 39
Offset: 0

Views

Author

Henry Bottomley, Apr 19 2000

Keywords

Comments

a(n) = -n in carryless arithmetic mod 10 - that is, n + a(n) = 0 (cf. A169894). - N. J. A. Sloane, Aug 03 2010

Examples

			a(11) = 99 because 1 + 9 = 0 mod 10 for each digit.
a(20) = 80 because 2 + 8 = 0 mod 10 and 0 + 0 = 0 mod 10.
		

Crossrefs

Column k=10 of A248813.

Programs

  • Haskell
    a055120 = foldl f 0 . reverse . unfoldr g where
       f v d = if d == 0 then 10 * v else 10 * v + 10 - d
       g x = if x == 0 then Nothing else Just $ swap $ divMod x 10
    -- Reinhard Zumkeller, Oct 04 2011
    
  • Maple
    f:=proc(n) local t0,t1,i;
    t0:=0; t1:=convert(n,base,10);
    for i from 1 to nops(t1) do
    if t1[i]>0 then t0:=t0+(10-t1[i])*10^(i-1); fi;
    od:
    RETURN(t0);
    end;
    # N. J. A. Sloane, Jan 21 2011
  • Mathematica
    a[n_] := FromDigits[ IntegerDigits[n] /. d_?Positive -> 10-d]; Table[a[n], {n, 0, 100}](* Jean-François Alcover, Nov 28 2011 *)
  • PARI
    a(n)=fromdigits(apply(d->if(d,10-d,0),digits(n))) \\ Charles R Greathouse IV, Feb 08 2017
    
  • Python
    def A055120(n): return int(''.join(str(10-int(d)) if d != '0' else d for d in str(n))) # Chai Wah Wu, Apr 03 2021

Formula

From Robert Israel, Sep 04 2017: (Start)
a(10*n) = 10*a(n).
a(10*n+j) = 10*a(n) + 10 - j for 1 <= j <= 9.
G.f. g(x) satisfies g(x) = 10*(1+x+x^2+...+x^9)*g(x^10) + (9*x+8*x^2+7*x^3+6*x^4+5*x^5+4*x^6+3*x^7+2*x^8+x^9)/(1-x^10).
(End)

A135601 Acute-angled numbers with an internal digit as the vertex.

Original entry on oeis.org

102, 103, 104, 105, 106, 107, 108, 109, 120, 130, 131, 132, 140, 141, 142, 143, 150, 151, 152, 153, 154, 160, 161, 162, 163, 164, 165, 170, 171, 172, 173, 174, 175, 176, 180, 181, 182, 183, 184, 185, 186, 187, 190, 191, 192, 193, 194, 195
Offset: 1

Views

Author

Omar E. Pol, Dec 02 2007

Keywords

Comments

The structure of digits represents an acute angle. The vertex is an internal digit. In the graphic representation the points are connected by imaginary line segments from left to right. This sequence is finite. The final term has 14 digits: 98765432102468.

Examples

			Illustration using the final term of this sequence:
  9 . . . . . . . . . . . . .
  . 8 . . . . . . . . . . . 8
  . . 7 . . . . . . . . . . .
  . . . 6 . . . . . . . . 6 .
  . . . . 5 . . . . . . . . .
  . . . . . 4 . . . . . 4 . .
  . . . . . . 3 . . . . . . .
  . . . . . . . 2 . . 2 . . .
  . . . . . . . . 1 . . . . .
  . . . . . . . . . 0 . . . .
		

Crossrefs

Programs

  • Python
    progressions = set(tuple(range(i, j+1, d)) for i in range(10) for d in range(1, 10-i) for j in range(i+d, 10))
    s = set()
    for left in progressions:
        for right in progressions:
            dl, dr = left[1] - left[0], right[1] - right[0]
            if dl + dr > 2:
                if left[-1] == right[-1]: s.add(left[:-1] + right[::-1])
                if left[0] == right[0]: s.add(left[::-1] + right[1:])
    afull = sorted(int("".join(map(str, t))) for t in s if t[0] != 0)
    print(afull[:53]) # Michael S. Branicky, Aug 02 2022

Formula

If a(n) does not end in 0, then A004086(a(n)) is a term; if a(n) does not start with 9, then A061601(a(n)) is a term. - Michael S. Branicky, Aug 02 2022

A267193 Complement obverse of n.

Original entry on oeis.org

9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 98, 88, 78, 68, 58, 48, 38, 28, 18, 8, 97, 87, 77, 67, 57, 47, 37, 27, 17, 7, 96, 86, 76, 66, 56, 46, 36, 26, 16, 6, 95, 85, 75, 65, 55, 45, 35, 25, 15, 5, 94, 84, 74, 64, 54, 44, 34, 24, 14, 4, 93, 83, 73, 63, 53, 43, 33, 23, 13
Offset: 0

Views

Author

N. J. A. Sloane, Jan 24 2016

Keywords

Comments

Replace digits of n by their 9's complements, reverse the order, omit any leading zeros.
Suggested by a posting by Mike Stay to the Math Fun Mailing List, Jan 24 2016, which in turn was loosely based on the definition used in logic (see the Philosophy Pages link).

Examples

			The 9's complement of the digits of 980 are 019, so a(980) = 910.
		

Crossrefs

Cf. A061601 (9's complement of n).

Programs

  • Maple
    a:= n-> (s-> parse(cat(seq(9-s[i], i=1..nops(s))))
             )(convert(n, base, 10)):
    seq(a(n), n=0..100);  # Alois P. Heinz, Jan 24 2016

Extensions

More terms from Alois P. Heinz, Jan 24 2016

A171960 Values of the 2-complement of n in ternary representation.

Original entry on oeis.org

2, 1, 0, 5, 4, 3, 2, 1, 0, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2
Offset: 0

Views

Author

Reinhard Zumkeller, Jan 20 2010

Keywords

Crossrefs

Programs

  • Mathematica
    a[n_] := 3^(1 + Floor[Log[3, n]]) - n - 1; a[0] = 2; Array[a, 100] (* Amiram Eldar, Apr 03 2025 *)
  • PARI
    a(n) = 3^(if(n,logint(n,3))+1) - 1 - n; \\ Kevin Ryde, Jul 16 2020

Formula

a(n) = if n < 3 then 2 - n else 3*a(floor(n/3)) + 2 - n mod 3.
a(A134026(n)) < A134026(n).
a(A003462(n)) = A003462(n).
a(A134025(n)) >= A134025(n).

A109002 Maximal difference between two n-digit numbers.

Original entry on oeis.org

9, 89, 899, 8999, 89999, 899999, 8999999, 89999999, 899999999, 8999999999, 89999999999, 899999999999, 8999999999999, 89999999999999, 899999999999999, 8999999999999999, 89999999999999999, 899999999999999999, 8999999999999999999, 89999999999999999999, 899999999999999999999
Offset: 1

Views

Author

Amarnath Murthy, Aug 14 2005

Keywords

Examples

			a(1) = 9 - 0 = 9, a(4) = 9999 - 1000 = 8999.
		

Crossrefs

Programs

  • Magma
    [9] cat [9*10^n-1: n in [1..30]]; // Vincenzo Librandi, Oct 29 2011
    
  • Mathematica
    Join[{9},Table[FromDigits[PadRight[{8},n,9]],{n,2,20}]] (* or *) LinearRecurrence[{11,-10},{9,89,899},20] (* Harvey P. Dale, May 09 2021 *)
  • PARI
    a(n)=if(n>1,(10^n-1)-10^(n-1),9) \\ Charles R Greathouse IV, Oct 29 2011

Formula

a(n) = (10^n - 1) - 10^(n-1), n > 1.
From Reinhard Zumkeller, May 28 2010: (Start)
a(n) = A061601(A178500(n-1)).
a(n+1) = 10*a(n) + 9. (End)
G.f.: 9*x - x^2*(-89+80*x)/((10*x-1)*(x-1)). - R. J. Mathar, Oct 29 2011
From Elmo R. Oliveira, Jun 12 2025: (Start)
E.g.f.: (1 + 10*x - 10*exp(x) - exp(10*x) + 10*exp(10*x))/10.
a(n) = 11*a(n-1) - 10*a(n-2) for n >= 4. (End)

A178500 a(n) = 10^n * signum(n).

Original entry on oeis.org

0, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 10000000000000, 100000000000000, 1000000000000000, 10000000000000000, 100000000000000000, 1000000000000000000, 10000000000000000000, 100000000000000000000
Offset: 0

Views

Author

Reinhard Zumkeller, May 28 2010

Keywords

Comments

a(n-1) is the minimum difference between an n-digit number (written in base 10, nonzero leading digit) and the product of its digits. For n > 1, it is also a number meeting that bound. See A070565. - Devin Akman, Apr 17 2019

Crossrefs

Programs

Formula

a(n) = A011557(n)*A057427(n).
For n > 0, a(n) = A011557(n).
a(n) = 10*A178501(n).
a(n) = A000533(n) - 1.
A061601(a(n)) = A109002(n+1).
From Elmo R. Oliveira, Jul 21 2025: (Start)
G.f.: 10*x/(1-10*x).
E.g.f.: 2*exp(5*x)*sinh(5*x).
a(n) = 10*a(n-1) for n > 1. (End)

A084021 Product of n and its 9's complement.

Original entry on oeis.org

0, 8, 14, 18, 20, 20, 18, 14, 8, 0, 890, 968, 1044, 1118, 1190, 1260, 1328, 1394, 1458, 1520, 1580, 1638, 1694, 1748, 1800, 1850, 1898, 1944, 1988, 2030, 2070, 2108, 2144, 2178, 2210, 2240, 2268, 2294, 2318, 2340, 2360, 2378, 2394, 2408, 2420, 2430, 2438
Offset: 0

Views

Author

Amarnath Murthy, May 23 2003

Keywords

Comments

There are infinitely many nonzero squares in this sequence; for example a(10^(4n) - 10^(2n)) = (10^n*(10^(2n)-1))^2. - David Wasserman, Dec 07 2004

Crossrefs

Cf. A061601.

Programs

Formula

a(n) = n*(10^d - 1 - n), where d is the number of digits in n.
a(n) = n*A061601(n). - David Wasserman, Dec 07 2004

Extensions

More terms from David Wasserman, Dec 07 2004
a(0)=0 prepended by Seiichi Manyama, Sep 15 2019

A160668 Distance between prime(n) and the next higher power of 10.

Original entry on oeis.org

8, 7, 5, 3, 89, 87, 83, 81, 77, 71, 69, 63, 59, 57, 53, 47, 41, 39, 33, 29, 27, 21, 17, 11, 3, 899, 897, 893, 891, 887, 873, 869, 863, 861, 851, 849, 843, 837, 833, 827, 821, 819, 809, 807, 803, 801, 789, 777, 773, 771, 767, 761, 759, 749, 743, 737, 731, 729, 723
Offset: 1

Views

Author

Enoch Haga, May 23 2009

Keywords

Examples

			a(1)=8 because 10^1=10, and 10-2, 1st prime 2, = 8;
a(5)=89 because 10^2=100 and 100-11, 5th prime 11, = 89.
		

Crossrefs

Programs

  • Magma
    [10^(Ceiling(Log(NthPrime(n))/Log(10))) - NthPrime(n): n in [1..30]]; // G. C. Greubel, May 02 2018
  • Maple
    a:= n-> (p-> 10^length(p)-p)(ithprime(n)):
    seq(a(n), n=1..100);  # Alois P. Heinz, Dec 08 2017
  • Mathematica
    Table[10^Ceiling[Log[Prime[n]]/Log[10]] - Prime[n], {n, 1, 100}] (* G. C. Greubel, May 02 2018 *)
  • PARI
    a(n) = 10^ceil(log(prime(n))/log(10)) - prime(n); \\ Michel Marcus, Dec 08 2017
    
  • UBASIC
    20 N=3:print N:C=2
    30 A=3:S=sqrt(N)
    40 B=N/A 50 if A*B=int(N) then 70
    60 A=A+2:if AEnoch Haga, May 22 2009
    

Formula

From Alois P. Heinz, Dec 08 2017: (Start)
a(n) = 10^A055642(A000040(n)) - A000040(n).
a(n) = A228628(n) + 1 = A061601(A000040(n)) + 1. (End)
Showing 1-10 of 30 results. Next