A152054 Bouncy numbers (numbers whose digits are in neither increasing nor decreasing order).
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
Links
- David F. Marrs, Table of n, a(n) for n = 1..10000
- Project Euler, Non-bouncy numbers Problem 113
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
Comments