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-2 of 2 results.

A152054 Bouncy numbers (numbers whose digits are in neither increasing nor decreasing order).

Original entry on oeis.org

101, 102, 103, 104, 105, 106, 107, 108, 109, 120, 121, 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, 196
Offset: 1

Views

Author

Jerome Abela (Jerome.Abela(AT)gmail.com), Nov 22 2008

Keywords

Comments

Complement of union of A009994 and A009996. - Ray Chandler, Oct 25 2011
Number of n-digit bouncy numbers is 9*10^(n-1) - (n+18)*binomial(n+8, 8)/9 + 10. - Altug Alkan, Oct 02 2018

Crossrefs

Cf. A152464. - Jon E. Schoenfield, Dec 06 2008

Programs

  • Mathematica
    Select[Range[0,200], !LessEqual@@IntegerDigits[#] && !GreaterEqual@@IntegerDigits[#]&] (* Ray Chandler, Oct 25 2011 *)
    bnQ[n_]:=Module[{didn=Differences[IntegerDigits[n]]},Count[didn,?(#>0&)]>0 && Count[didn,?(#<0&)]>0]; Select[Range[100,200],bnQ] (* Harvey P. Dale, Jun 13 2020 *)
  • Python
    a = 1
    b = 100
    while a != 51:
        if str(b) != ''.join(sorted(str(b))) and str(b) != ''.join(sorted(str(b)))[::-1]:
            print(b)
            a += 1
        b += 1
    # David F. Marrs, Sep 25 2018
    
  • Python
    from itertools import count, islice
    def A152054_gen(startvalue=1): # generator of terms >= startvalue
        for n in count(max(startvalue,1)):
            l = len(s:=tuple(int(d) for d in str(n)))
            for i in range(1,l-1):
                if (s[i-1]-s[i])*(s[i]-s[i+1]) < 0:
                    yield n
                    break
    A152054_list = list(islice(A152054_gen(),30)) # Chai Wah Wu, Jul 28 2023

Extensions

More terms from Jon E. Schoenfield, Dec 06 2008

A343462 Number of n-digit positive integers that undulate.

Original entry on oeis.org

9, 81, 525, 3105, 18939, 114381, 693129, 4195557, 25405586, 153820395, 931359050, 5639156409, 34143908573, 206733865761, 1251728824798, 7578945799704, 45888871327435, 277847147039527, 1682304127857000, 10185986079451152, 61673933253012813, 373422269794761171, 2260990733622821388
Offset: 1

Views

Author

David A. Corneth, Apr 16 2021

Keywords

Comments

This is also the number of (2*n-1)-digit palindromes that undulate.
Classifying undulating numbers with n digits in initial digits and sign of first digit - second digit eases computation.

Examples

			a(2) = 81 as there are 90 2-digit positive integers (10, 11, ..., 99). Of those, 11, 22, ..., 99 do not undulate as there is a pair of consecutive digits that are equal. There are nine nonundulating 2-digit numbers, leaving 90-9 = 81 that do undulate.
134 does not undulate as there are two pairs of consecutive digits where the right one is in both cases either smaller or larger. (In this case 1 < 3 and 3 < 4.)
143 does undulate since 1 < 4 and 4 > 3.
		

Crossrefs

Cf. A057332. Apart from the first 2 terms, the same as A152464.

Programs

  • PARI
    first(n) = { my(res = vector(n), vup, vdown, nvup, nvdown); res[1] = 9; vup = vector(9, i, 1); vdown = vector(9, i, 1); for(i = 2, n, nvup = vector(9); nvdown = vector(9); nvdown[1] = vdown[9]; for(i = 2, 9, nvdown[i] = nvdown[i-1]+vup[i-1] ); for(i = 1, 8, nvup[i] = nvdown[9-i] ); vup = nvup; vdown = nvdown; res[i] = vecsum(vup)+vecsum(vdown)); res }
    
  • Python
    def aupton(terms):
      up, dn, alst = [0] + [1]*9, [0] + [1]*9, [9]
      for n in range(2, terms+1):
        up_next = [sum(dn[j] for j in range(i)) for i in range(10)]
        dn_next = [sum(up[j] for j in range(i+1, 10)) for i in range(10)]
        up, dn = up_next, dn_next
        alst.append(sum(up + dn))
      return alst
    print(aupton(22)) # Michael S. Branicky, Apr 16 2021
    
  • Python
    # alternate program as a linear system
    import numpy as np
    from sympy import Matrix
    def aupton(terms):
      x = Matrix([0] + [1]*9 + [0] + [1]*9)
      c = Matrix([[1]*20])
      z10 = np.zeros((10, 10), dtype=np.int64)
      o10 = np.ones((10, 10), dtype=np.int64)
      A = Matrix(np.block([[z10, np.tril(o10, -1)], [np.triu(o10, +1), z10]]))
      alst = [9]
      for n in range(2, terms+1):
        x = A*x
        alst.append((c*x)[0])
      return alst
    print(aupton(22)) # Michael S. Branicky, Apr 16 2021

Formula

a(n) = 45*a(n-2) - 330*a(n-4) + 924*a(n-6) - 1287*a(n-8) + 1001*a(n-10) - 455*a(n-12) + 120*a(n-14) - 17*a(n-16) + a(n-18) for n >= 20. - Michael S. Branicky, Apr 17 2021
From Chai Wah Wu, Apr 24 2021: (Start)
a(n) = 5*a(n-1) + 10*a(n-2) - 20*a(n-3) - 15*a(n-4) + 21*a(n-5) + 7*a(n-6) - 8*a(n-7) - a(n-8) + a(n-9) for n > 10.
G.f.: x*(-8*x^9 + 7*x^8 + 63*x^7 - 45*x^6 - 162*x^5 + 81*x^4 + 150*x^3 - 30*x^2 - 36*x - 9)/(x^9 - x^8 - 8*x^7 + 7*x^6 + 21*x^5 - 15*x^4 - 20*x^3 + 10*x^2 + 5*x - 1). (End)
Showing 1-2 of 2 results.