Continuants, run lengths, and Barry's modified Pascal triangle

We show that the $n$'th diagonal sum of Barry's modified Pascal triangle can be described as the continuant of the run lengths of the binary representation of $n$. We also obtain an explicit description for the row sums.


Introduction
In 2006 in the On-Line Encyclopedia of Integer Sequences (OEIS) [8], sequence A119326, Paul Barry introduced a modified Pascal triangle, defined for integers 0 ≤ k ≤ n, as follows: The first few rows of this triangle are as follows: Similarly, one can consider T (n, k) mod 2, whose terms are given by sequence A114213: Sequences A114212 and A114214, respectively, are the row sums and diagonal sums of this latter triangle. We denote them by r(n) and d(n), respectively: In May 2016, the first author observed, empirically, a connection between d(n) and the binary representation of n. In this note we prove this connection, and also prove a formula for r(n). The connection involves Stern's "diatomic sequence" s(n), defined by s(0) = 0, s(1) = 1, s(2n) = s(n), and s(2n + 1) = s(n) + s(n + 1); see [9].

The diagonal sums
Let the binary representation of n be denoted by j i=0 ε i (n)2 i . We show that the diagonal sum d(n) can be expressed in terms of this representation. Given a string s of 0's and 1's, we consider its run lengths: the lengths of maximal blocks of consecutive identical elements. For example, if s = 111000011111, then the run lengths of s are (3,4,5).
If m is a sequence of positive integers, we may associate an integer with it via the continued fraction expansion: if m = (m 0 , . . . , m k ), we say that the continuant of m is the numerator of the continued fraction [m 0 ; m 1 , . . . , m k ] (see [3,Ch. 34, §4]). Theorem 2.1. Let n ≥ 0 be an integer and let m be the sequence of run lengths of the binary representation of n. Then d(n) equals the continuant of m.
We will use Lucas' famous congruence for binomial coefficients [7, p. 230]: if p is a prime number and n = (n ν · · · n 0 ) p and k = (k ν · · · k 0 ) p , then This implies that n k is not divisible by p if and only if k i ≤ n i for all i. Moreover, it follows that the number of odd binomial coefficients n k equals 2 s2(n) , where s 2 is the binary sum-of-digits function [4].
We prove the following statement, which reduces the problem to divisibility by 2 of binomial coefficients. We will derive Theorem 2.1 from it in a moment.
Proof. We prove the first statement. By replacing n with n + k we get the equivalent assertion that if 2 | n or 2 | k, then By Lucas' congruence the left-hand side is congruent to where n∧k is the integer whose binary digits satisfy ε i (n∧k) = min(ε i (n), ε i (k)). This expression is odd if and only if s 2 (n ∧ k) = 0, which is the case if and only if the binary representations of n and k are disjoint. To handle the right-hand side of Eq. (1), we note that n+k k is odd if n ∧ k = 1. On the other hand, if the binary representations of n and k are not disjoint, then the condition ε i (k) ≤ ε i (n + k) is violated for i = min{j : ε j (n) = 1, ε j (k) = 1}; therefore n+k k is even. This proves the first assertion.
For the second assertion, we use Lucas' congruence again: for 2 | j and 2 | m we have m j ≡ m+1 j (mod 2). Since 2 ∤ n − k, we obtain n−k j ≡ n−1−k j (mod 2). Moreover, by 2 ∤ n − k the ranges of summation in T (n, k) and T (n − 1, k) are the same.
It is well-known [5,6] that if m = (m 0 , . . . , m k ) is the sequence of run-lengths of the binary representation of n and n is odd, then s(n) is the continuant of m. Therefore d(n) is the continuant of m. In order to complete the proof of the conjecture, we have to show that the same is true for even n. By Eq. (3) it is sufficient to prove the following lemma. Lemma 2.3. If n is even, then the continuant of the sequence of run-lengths of the binary representation of n is equal to the continuant corresponding to n + 1.

The row sums
We will prove Theorem 3.1.
A similar characterization was stated, without proof or attribution, in the notes to A114212 of the OEIS.