OFFSET
1,2
COMMENTS
For n > 1 the structure of digits represents a mountain. The first digit is 1. The last digit is 1. The first digits are in increasing order. The last digits are in decreasing order. The numbers only have one largest digit. This sequence is finite. The last term is 12345678987654321.
The total number of terms is 21846. - Hans Havermann, Nov 25 2007
A002450(8) + 1 = 21846. - Reinhard Zumkeller, May 17 2010
From Reinhard Zumkeller, May 25 2010: (Start)
A178334(n) is the number of mountain numbers <= n;
A178051(n) is the peak value of the n-th mountain number. (End)
LINKS
Joshua Zucker, Table of n, a(n) for n = 1..21846 (shows all terms).
EXAMPLE
The A-number of this sequence (A134941) is itself a mountain number:
. . . 9 . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . 4 . 4 .
. 3 . . . .
. . . . . .
1 . . . . 1
MATHEMATICA
mountainQ[n_] := MatchQ[ IntegerDigits[n], {1, a___, b_, c___, 1} /; OrderedQ[{1, a, b}, Less] && OrderedQ[ Reverse[{b, c, 1}], Less]]; mountainQ[1] = True; Select[Range[2000], mountainQ] (* Jean-François Alcover, Jun 13 2012 *)
Prepend[Union @@ ((FromDigits@#&/@Flatten[Table[Join[(k=Prepend[#, 1]&/@
Subsets[Range[2, #-1]])[[i]], {#}, (Reverse@# & /@k)[[j]]],
{i, 2^(# - 2)}, {j, 2^(# - 2)}], 1])&/@Range[9]), 1] (* Hans Rudolf Widmer, Apr 30 2024 *)
PROG
(Haskell)
import Data.List (elemIndices)
a134941 n = a134941_list !! (n-1)
a134941_list = elemIndices 1 a178333_list
-- Reinhard Zumkeller, Oct 28 2001
(Python)
from itertools import product
def ups():
d = "23456789"
for b in product([0, 1], repeat=8):
yield "1" + "".join(d[i]*b[i] for i in range(8))
def downsfrom(apex):
if apex < 3: yield "1"*int(apex==2); return
d = "8765432"[-(apex-2):]
for b in product([0, 1], repeat=len(d)):
yield "".join(d[i]*b[i] for i in range(len(d))) + "1"
def A134941(): # return full sequence as a list
mountain_strs = (u+d for u in ups() for d in downsfrom(int(u[-1])))
return sorted(int(ms) for ms in mountain_strs)
print(A134941()[:45]) # Michael S. Branicky, Dec 31 2021
CROSSREFS
KEYWORD
base,fini,full,nonn
AUTHOR
Omar E. Pol, Nov 22 2007
STATUS
approved