login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Mountain Sequence: Sequence that when expressed as non-overlapping mountains, the n-th term is the height and base of the n-th mountain.
1

%I #22 Jul 30 2024 15:21:03

%S 1,2,1,2,3,4,3,2,1,2,1,2,3,4,3,2,3,4,5,6,5,4,3,4,5,6,7,8,7,6,5,4,3,4,

%T 5,6,5,4,3,2,3,4,3,2,1,2,1,2,3,4,3,2,1,2,1,2,3,4,3,2,3,4,5,6,5,4,3,4,

%U 5,6,7,8,7,6,5,4,3,4,5,6,5,4,3,2,3,4,3,2,3,4,5,6,5,4,3,4,5,6,7,8,7,6,5,4

%N Mountain Sequence: Sequence that when expressed as non-overlapping mountains, the n-th term is the height and base of the n-th mountain.

%C A mountain with base b and height h is a segment starting with b, then climbs to b+h, and goes back to b. So as an example, (1, 2, 3, 2, 1) is a mountain with base of 1 and height of 2.

%C All positive integers appear in the sequence infinitely many times.

%H Bryle Morga, <a href="/A375088/b375088.txt">Table of n, a(n) for n = 1..16384</a>

%H Bryle Morga, <a href="/A375088/a375088.png">Visualization of the first 10,000,000 terms.</a>

%F |a(n+1) - a(n)| = 1.

%e a(1) = 1, so the first non-overlapping mountain is 1, 2, 1 with h = b = 1.

%e Now, a(2) = 2, so the mountain 2, 3, 4, 3, 2 with b = h = 2 is appended to the sequence, and so on.

%o (Python)

%o from itertools import islice

%o def mountain(h):

%o return list(range(h, 2*h + 1)) + list(range(2*h-1, h-1, -1))

%o def agen():

%o a = [1, 2, 1]

%o yield 1

%o i = 1

%o while 1:

%o a += mountain(a[i])

%o yield a[i]

%o i += 1

%o print(islice(agen(), 104))

%K nonn,look

%O 1,2

%A _Bryle Morga_, Jul 29 2024