Structure of Triangular Numbers Modulo m

: This work focuses on the structure and properties of the triangular numbers modulo m . The most important aspect of the structure of these numbers is their periodic nature. It is proven that the triangular numbers modulo m forms a 2 m -cycle for any m . Additional structural features and properties of this system are presented and discussed. This discussion is aided by various representations of these sequences, such as network graphs, and through discrete Fourier transformation. The concept of saturation is developed and explored, as are monoid sets and the roles of perfect squares and nonsquares. The triangular numbers modulo m has self-similarity and scaling features which are discussed as well.


Introduction
The current work is part of a special issue on the application of number theory in sciences and mathematics and is centered on triangular numbers. More specifically, it is focused on the triangular numbers modulo m, where m is any non-negative integer. Such numbers form a periodic sequence which has an interesting structure. That structure is explored here via elementary number theory, graph theory, and numerical analysis.
The triangular numbers (sometimes called the triangle numbers) are arguably the most well-known of the sequences of polygonal numbers (see [1], chapter 1), which include the square numbers, pentagonal numbers, hexagonal numbers, etc. As the name implies, the polygonal numbers are the sequences formed by counting lattice points cumulatively in subsequent n-gonal patterns. Triangular numbers arise from a triangular lattice. However, triangular numbers are perhaps best known because they represent the cumulative sums of the integers. Each member of the (infinite) sequence of triangular numbers is obtained via a simple closed-form formula per the following definition. Definition 1. Triangular numbers. The set of triangular numbers is, for n ∈ N, T ≡ T(n) = n(n + 1) 2 .
Note, throughout this work, we are taking N to include zero (so, the non-negative integers). The triangular numbers themselves have a long and interesting history [2,3], including the fact that major insight was provided by Gauss himself (see [4], page 91). In spite of all this attention, there is a dearth of literature focused on the triangular numbers mod m ∈ N + [5]. To be sure, many ideas associated with this set can be found spread through online mathematics communities in forums and blog posts. A number of these ideas, including theorems, are collected in the current work to assist the reader by providing a self-contained presentation. In related work, Wall considered the Fibbonacci numbers modulo m [6] in the early 1960s. Subsequent work on Fibbonicci numbers over cyclic groups was performed by Dikici and coworkers [7][8][9].
The purpose of the current work is to investigate the fascinating structural characteristics of the triangular numbers modulo m. In addition to presenting some new theorems regarding the triangular numbers modulo m, use is made of modern computing power to illustrate some unproven conjectures, which might be useful in applied settings, such as statistical mechanics or computer science. The structure of triangular numbers modulo m reveals a variety of self-similarity and scaling characteristics.
In this work, the designation of a conjecture will be reserved for results in which the author does not have a complete proof. The designation of a proposition will be used for conjecture-like ideas that do have a proof. Lemma, theorem, and corollary designations will be used in their typical ways. Numerical work was done using in-house-made MATHEMATICA and Python code. Network analysis on graphs was done using GEPHI.

Information and Data Compression
Before launching into the details of the structure of the triangular numbers modulo m, this section provides an overarching view of the types of sets one is interested in. Here too, the definitions of the sets are given.

Sets and Sequences
The triangular numbers themselves, T = {0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, . . .} (series A000217 in the Online Encyclopedia of Integer Sequences [10]) constitute one member of the set of infinite sequences defined here as S ∞ . Other members of this set include the infinite sequence of the triangular numbers modulo m, T mod m. For example, T mod 6 = {0, 1, 3, 0, 4, 3, 3, 4, 0, 3, 1, 0, 0, 1, 3, . . .}. As mentioned above, the most striking feature of the triangular numbers modulo m is that they are 2m periodic for all m. This will be proved (Theorem 1) and discussed more below. This suggests that there is value in naming a family of finite sequences. Each set is labeled S 2m , representing the specific set of sequences of length 2m. For a given m, the infinite sequence T mod m maps to a single point in S 2m . T m ≡ {the first 2m members of T mod m}.

Remark 1.
The reader is cautioned to note that the subscript on the element, T m is m, whereas on the set it is 2m, S 2m . This notational inconsistency will pay off in the end because m itself will play such an important role in the current analysis.
Two other sets of sets will be important in the current analysis. The first has as elements the set of residue classes present in a given sequence. This is referred to as the set of occupancy set and labeled O m . The point in this set corresponding to T m is labeledT m . For example,T 6 = {0, 1, 3, 4}. This leads to the following definition Definition 3. The occupancy set.T m ≡ {distinct residues in T m }.
The second set is the set of multiplicity set, labeled, Λ m , in which each element, Λ m , is the listing of multiplicities of each member ofT m in the first m (not 2m) members of T m . As an example,λ 6 = {2, 1, 2, 1}. Definition 4. The multiplicity setλ m ≡ {number of times each distinct residue appears in the first m elements of T m }. Note that the order of the elements inλ m corresponds to the order of the elements inT m .

Information Content of Sets
For the purpose of this work, by "information" we mean how much information is needed to give an explicit listing of a particular sequence. At present, the information unit is generic, but one could, for example, consider the unit as a computer-based calculation unit. Thus, for the triangular numbers themselves, the information needed is infinite (in spite of the closed-form formula). For T m , the amount of information needed is 2m units. Figure 1 shows a schematic representation of the various sets arising in the present analysis. The top row shows the progression from the set of infinite sequences, S ∞ , to the set of finite sequences of length 2m. Theorem 1 (proven below) compresses the 2mperiodic sequence of the triangular numbers modulo m without loss of information. Then, via Theorems 2 and 3, another two-fold compression is achieved by mapping the length 2m sequences to the corresponding length m sequences. This is also a lossless mapping due to the nature of the sequences of residue classes as contained in Theorems 2 and 3 (proven below).
The second row of Figure 1 shows the, again, roughly two-fold compression mapping of the sequences of length m to the corresponding sequences of length m+1 2 . In terms of information loss, we see a divergence between the m in an even case and the m in an odd case. Due to Theorem 4, the odd m case remains lossless. This is not the true for the case when m is an even integer. Lossless compression of information about the sequence of triangular numbers modulo m based on Theorems 1-3. Second row: Application of Theorem 4. Note for odd values of m, this information compression is lossless. It is lossy, however, when m is even. Bottom row: Mapping of the ordered sequences in S m to the unordered sets. As the order is lost, these maps are lossy. Data compression is dependent on the specific value of m. This data compression finally results in the representation of the sequence of triangular numbers modulo m as saturation, 0 ≤ s ≤ 1 via Definition 5.
The bottom row (along with S m ) of Figure 1 shows further compression of information about the sequence of triangular numbers modulo m. All of these mapping are sequentially lossier and lossier, but nonetheless, still lead to sets carrying important information about the sequences. The first map brings the ordered sequence from S m to the Cartesian product of the occupancy set, O m , and the multiplicity set, Λ. The data compression here is variable depending on the nature of m. This is discussed in more detail below. Projecting away, the multiplicity set gives two-fold compression. Finally, the definition of saturation, s = |T m | |Z m | , gives a representation of the sequence as a single real number 0 ≤ s ≤ 1 (formally defined in Definition 5).

Main Structure Theorems
The most immediate and critical structural feature of the triangular numbers modulo m is their periodic nature. This is important for a number of reasons but most importantly in reducing an infinite non-repeating sequence to an infinite but repeating sequence of period 2m. This reduction allows for the properties of this sequence to be studied via a 2m-member sequence of residue classes. Remarkably, this is the case for any m. Further, theorems dealing with symmetry present in T m are also given.
The general structure of the triangular numbers modulo m is captured in the following theorems.

Main Cycle Structure Theorem
Theorem 1. The sequence of triangular numbers mod m is a 2m-cycle. Additionally, the sequence is symmetric about the "midpoint" of the 2m-cycle. That is, the last m elements are the reverse sequence to that of the first m elements.
Proof. The 2m-cycle part. Define ∆ ≡ T(2m + j) − T(j). Then, Expansion and simplification leads to Under modulo m, ∆ mod m = 0. The symmetry part. Again define a difference, but now ∆ ≡ T(m + j − 1) − T(m − j). This is written out as Expansion and simplification leads to Under modulo m, ∆ mod m = 0.
Some context is required for the last two sentences of Theorem 1 and the last sentence of the proof. Of course given a T m , one could choose a different member of the equivalence class by starting the cycle at any point, thereby breaking the symmetry, and then the sequence would no longer begin and end with zero. The context here is that the statements about symmetry hold true when the cycle is initiated, with the first member being T(0) = 0.
There are some situations when it is also natural to initiate the cycle with the first member being T(1) = 1. In those situations, the cycle ends with two consecutive zeros.

Symmetry Theorems
Two related theorems are the following. These deal with the respective symmetries for the odd and even cases.

Theorem 2.
For odd values of m, the triangular numbers' moduli m form an m-cycle.
Proof. As in the previous theorem, define a difference: ∆ ≡ T(m + j) − T(j). Now one can take advantage of the fact that two has an inverse when m is odd. As such, one can consider 2∆ = (m + j)(m + j + 1) − j(j + 1).
Expansion and simplification leads to Under modulo m, 2∆ mod m = 0. This implies ∆ mod m = 0 (because 2 has an inverse) and thus proves the assertion of the theorem.
Corollary 1. The mth member of T m is m 2 when m is even.
Match the terms on the right hand side as m + j + (m + (j − 1)) + . . . + (m + 1) This gives Substituting in for m gives Modulo m gives ∆ = 0.
The working example of T 15 , along with T 7 and T 9 , given the above shows this feature.

Lemma 1.
The triangle numbers' moduli m are the values of a ∈ Z m that give solutions to either of the following two congruence relations: (i) n(2n + 1) = a and (ii) n(2n − 1) = a.
Thus, n(2n + 1) = a mod m and n(2n − 1) = a mod m define the congruence relations in Z m which gives the allowed values of a ∈ Z m . Theorem 5. The set of unique triangle numbers moduli m ∈ N + ,T m , are all a ∈ Z m such that 1 + 8a mod m = n 2 mod m for some n ∈ Z m . That is, all a for which 1 + 8a mod m is a perfect square under the modulo.
Proof. One notes that from Lemma 1, the members of T m will be all a such that either n(2n + 1) = a or n(2n − 1) = a yield solutions. It turns out one can more succinctly consider n(2n ± 1) = a and deal with both congruence relations at once.
Considering the solutions to the quadratic congruence 2n 2 ± n − a = 0, one can write The important part of this relation is (1 + 8a). The set of solutions to the above congruence is given precisely by those values of a in which 1 + 8a is a perfect square under modulo m. This completes the proof.
At first glance, it seems as though the problem of finding the allowed a might well degenerate into a number of "solvable" cases involving primes, powers of primes, etc., as is often the case when considering quadratic congruences. This is not the case here, however, because one is not looking for a solution to the quadratic congruence per se, but only looking to determine if a particular a yields a solution. These values will be precisely the set listed in Theorem 5.
As an illustrative example of the use of Theorem 5, consider the case of modulo 10. Here the set of perfect squares are {0, 1, 4, 5, 6, 9}, and the set of ordered pairs is (a, 1 + 8a mod 10) = {(0, 1), (1,9) It is also noteworthy that Theorem 5 does not have a great deal of power in the applied setting because it does not give a specific mechanism for finding which a make upT m , nor does it give the multiplicity of a. That is,T m loses information about the ordered set T m . Finally, Section 7.2 takes a closer look at perfect squares and their relation to the members ofT m . Theorem 6. If m is even, there are equal numbers of even and odd numbers in the first m members of the 2m-cycle of Theorem 1.
Proof. Let m = 2n and consider the size 2n set for j = 0 to j = 2n − 1. The role of modulo 2 is to make A simply a set of even (0) and odd (1) numbers. Expanding the above expression gives The first two terms vanish under the mod. Considering j(j+1) 2 mod 2 and Theorem 1 yields the 4-cycle {0, 1, 1, 0, repeat}. Regardless of whether n is 1 or 0, there are the same numbers of even and odd entries in set A.
Consider the case of T 8 , T 10 , and T 12 given earlier. Indeed there are 4, 5, and 6 evens, respectively, and the same for odds.

Specific Structure Theorems
Some specific characteristics of the structure of the triangular numbers mod m are discussed here. First, the case of m = 2 j , where j ∈ N + . Then, the cases in which m is prime or prime power are presented.

Theorems Related to m = 2 n
Theorem 7. If m = 2 n and n ∈ N + , then the first time 0 reappears is at a position less than or equal to the m − 1 position. The converse is also true.
Proof. Write m = 2 j c and observe that 2 j and c are relatively prime. Consequently, the Chinese remainder theorem implies that there exists a nonzero a ∈ N + such that a mod 2 j+1 = 0 and a mod c = −1 and that a is uniquely determined modulo 2 j+1 c. Since 2 j+1 c = 2m, 0 < a ≤ 2m − 1. Now, a mod 2 j+1 = 0 and a + 1 mod c = 0. Thus, a(a + 1) mod 2 j+1 c = a(a + 1) mod 2m. This implies a(a+1) 2 mod m = 0. This leads to two cases: Finally, c = a or b appropriately such that 0 < a ≤ m − 1 and T(c) mod m = 0.
The converse follows quickly because if 0 reappears prior to the m − 1 position in the sequence, then it has appeared at least twice overall (the first time being at position 0 itself). Then, by Theorem 8, m = 2 n , as is shown next.
The working examples of T 10 and T 15 bear this out. For T 10 zero reappears at position 5, and for T 15 it reappears at position 6. Proof. The if part of the proof will be by induction. In general, one is given that m = 2 n . For the base case m = 2 and under these conditions, T(i) mod m = 0 or 1. Hence, the base case is true. One then assumes it is true that all values appear once and only once in the first m members of the 2m-cycle if m = 2 j and one considers the case when n = j + 1. Let Now ∆ mod m = 0 and thus T(b) = T(a) for all 0 ≤ a ≤ m − 1 modulo m and by the assumption of the jth inductive step, all values appear once and only once. However, ∆ mod 2m = 0 for all 0 ≤ a ≤ m − 1. Since m ≤ 2b + 1, all new values up to 2m − 1 must appear once and only once. As 2m = m j+1 , this completes the if part of the proof.
The only if part follows from Theorem 7, given all values appear once and only once in the first m members of the 2m-cycle. Let m = 2 j m ; then, by Theorem 7, there exists an a such that 0 < a ≤ m − 1 and T(a) mod m = 0. However, 0 is also the first value. This poses a contradiction and completes the proof.
Corollary 2. If m = 2 n , then at least one value has a multiplicity greater than one (appears more than once). The converse is also true.
Proof. Follows immediately from the pigeonhole theorem, and the converse follows from Theorem 8.

Theorems Involving Cases When m is Prime
Proof. Assume T(a) = a(a+1) 2 = 0 mod m. As m is prime, Z m is a field. Together, this implies either a = cm or (a + 1) = cm, where c ∈ Z. However, this contradicts the stipulation on a in the theorem.
Writing out the triangle numbers gives Expanding and factoring out a b − a yields The imposed limits on a and b ensure (a + b) = m and (b − a + 1) = 0. Further, because m is prime, Z m is a field; thus, ∆ = 0. This completes the proof.
Proof. Since m is odd, two has an inverse. Thus, one considers 2T(a) = a(a + 1) and 2T(a + 1) = (a + 1)(a + 2). These terms share (a + 1) as a factor. Consequently, 2T(a) and 2T(a + 1) must lie in either the same row or same column of the multiplication Caley table ( [11], page 43). Since Z m is a field (multiplication in Z + m forms a group), T(a) = T(a + 1).

Theorems Involving Cases When m Is a Prime Squared
Proof. We start with Now one must consider the cases when a is even and odd. If a = 2b is even, If a = 2b + 1 is odd, This proves the lemma.
Theorem 11. For m = p 2 where p is an odd prime, residues appear only once in the first m+1 2 , except for the residue class equivalent to T p− 1 2 , which appears exactly p+1 2 times.
Proof. It is convenient to consider residues centered on Without loss of generality, one can take r 1 > r 2 . Writing out ∆ and simplifying gives One can immediately pick up the last statement of the theorem by setting r 2 = 0. Then, which equals zero modulo p 2 if and only if r 1 = jp. The if part of the theorem comes directly with substitution and hence proves the last statement. The only if part of the theorem comes from the fact that for ∆ = 0 mod p 2 r 1 (p + r 1 ) = ap 2 , but the only factors in ap 2 are a and p and the factors on the left-hand side are not those.
To get the first part of the statement, one makes two steps. First, make the restriction, r 1 = x + jp and r 2 = y + jp, such that 0 < y < x < p. This will scan the range between p−1 2 + jp and p−1 2 + (j + 1)p. Here, Finally, denote the multiplicative inverse of two, which exists under modulo p 2 , as 2 − . This gives, Given that 2 − = p, ∆ cannot be zero modulo p 2 for v = 0, which is the case for v.
The last step is to show that no two resides that differ by multiples of p are equal in the first m+1 2 members of the sequence. Again define the difference, Upon modulo p 2 , the first and third terms go to zero.
Thus, these combined facts, along with Theorem 4, which states that the first m+1 2 elements fully determine T m , complete the first statement of the theorem.

Property Theorems
Several properties of the triangular numbers modulo m are collected and discussed in this section.
Proof. As has been done often prior, define Writing everything out and simplifying gives Applying modulo m gives ∆ = 0 and completes the proof.
Proof. That m is odd implies that two has an inverse. With that, the direct route is taken. Upon substitution, Expanding and simplifying gives which becomes 2T(b) = 2T(a) under modulo m. Since two has an inverse, the proof is completed.
Proof. Noting that m must be odd and using the fact that two has an inverse, the direct route is taken.
The first two terms constitute 2T q− 1 2 , and the last three become q 2 (j + j 2 ), which vanish under modulo m = q 2 . Thus, and multiplying by two's inverse completes the proof.
Proof. The direct route is taken.
This completes the proof.
Proof. Both (a) and (b) will be proven simultaneously.
Then, by Theorem 7, one can certainly set T(q − j) mod m = 0. One then solves for j: For this relation to hold for any q, either j = 0 or j = 1, because the last term must always vanish. These give the two cases T(q) mod m = 0 and T(q − 1) mod m = 0, respectively.

Saturation Theorems
The scheme of information compression captured in Figure 1 ultimately compresses the triangular numbers modulo m down to a single real number between 0 and 1. This parameter, s, is called saturation. While much information is lost from the original sequence, the behavior of saturation with m still possesses very interesting features.   Proof. From Theorem 9 the residues, 0 ≤ r ≤ p−1 2 , determines the sequence for m = p, where p is an odd prime. From Theorem 4, the first p+1 2 members are distinct from one another. Thus, which proves the proposition.
Propositions 2 and 3 describe the sequence of points that swoop into an asymptotic value of s = 1 2 . Thus, the set of primes follows this behavior.
Theorem 17 (Reference [12], page 107). If gcd(q,r)=1, then Z qr is isomorphic to Z q × Z r under the ring isomorphism, η : Z qr → Z q × Z r defined by η(a) = (a mod q, a mod r).
Theorem 18. For m = ∏ r j p j , where the p j are distinct primes, s m = ∏ r j s j .
One can determine |T p j | and |Z p j | for each prime factor in the Cartesian product. Thus, Thus, which completes the proof.
One can consider the special case of two primes, p 1 and p 2 . By Theorem 18, An interesting limit is when one of the primes becomes very large compared to the other.
This leads to a number of the asymptotic striations seen in Figure 2.
where the partial product formula is used in the penultimate step.
Theorem 18 and Proposition 4 describe the points "dripping" off the main group. They are the points where m is a highly composite number of distinct primes.
which completes the proof.

Conjecture 2.
If m = 2 n q, where q is odd, then s 2 n q = s q .

Special Sets
Two special sets are considered in this section: first, sets that are monoids (closed under multiplication), and second, sets of perfect squares and nonsquares.

Monoids and Reduced Monoids
When considering the triangular numbers themselves, one finds several special multiplicative relations between the members of the set such as T(3) 2 = T(8). Once the triangular numbers are taken, moduli m with more multiplicative relations can potentially appear. To be sure, the multiplication of two triangular numbers does not always produce other triangular numbers (3 × 6 = 18 for example). One might wonder if there are any values of m such that this relation is true under modulo m. If so, the setT m would form a monoid under multiplication. Investigation of this leads to the following theorem. It remains to be shown that 2 a 3 b , when a > 0 and b is 1 or 2, is a monoid. To begin, consider 2 a 3 1 . It is quick to calculate that all triangular numbers are 0 or 1 mod 3. Meanwhile, via Theorem 8, all residues are present inT 2 a . Now, via the Chinese remainder theorem see ( [11], page 259), the modulo 2 a 3 1 of any product of triangular number is uniquely determined by that product modulo 2 a and modulo 3. This implies that all residues for products are present inT 2 a 3 1 , and hence, it is a monoid.
To achieve a similar result for m = 2 a 3 2 , one uses the explicit verification of the monoid structure ofT 9 above. Then, as for m = 2 a 3 1 , all residues for products are present inT 2 a 3 2 , and hence, it is a monoid.
As a concrete example, considerT 12  and it, indeed, has a monoid structure (but not a group structure).

Conjecture 4. (Converse of Theorem 19
). If m = 2 a 3 b where a ∈ N and b ∈ 0, 1, 2, then T m is not closed, and thus not a monoid.
The above analysis shows that most values of m do not result in monoid structure. One can, however, define a reduced monoid by including only those members ofT m which form a closed subset under multiplication. These sets will be denoted asT Beginning with m = p being prime, one finds a particularly simple form given by the following proposition. Proof. For this proof, two well-known ideas from group theory are needed. First, the multiplicative group modulo p is cyclic. Second, the only subgroups of a cyclic group of prime order are the trivial group and the full group. Now, in the Caley table for this case, the non-zero rows and columns must be consistent with a group in that there must be no repeated entries in any column or row. For the subset of triangular numbers modulo p to be a monoid, they must form a subgroup. However, from the above, the subgroups are either the full group or the group consisting only of the identity. Including zero, the full monoid set is {0, 1}, which proves the proposition.
Proof. From Theorems 5 and 9, |T p | = p+1 2 . From Proposition 6, |T (mon) p | = 2. Thus, M r (p) = 4 p+1 . Figure 3 shows a plot of M r versus m for the first 15,000 integers. As with other quantities, the scatter plot shows striations. One sees many types of striations, horizontal lines, and hyperbolic-like curves. Due to Theorem 19, the values of M r = 1 occur when m = 2 a 3 b in the case when a is a non-negative integer and b is an integer such that b ≤ 2. Of note, the points seen at approximately M r = 0.9 are of the form m = 2 a 3 3 .

Perfect Squares and Nonsquares
Related to the previous section, another natural question to investigate is how are the perfect squares and the nonsquares distributed within T m . It is convenient to define Q(m) as the ratio of the number of nonsquares to the number of perfect square for modulo m. Analogously, Q T (m) is defined to be the number of nonsquares for modulo m that are also in T m to the number of perfect squares for modulo m that are also in T m . Using this, one has the following useful parameter.

Definition 7. Nonsquare excess. R(m) ≡ Q T (m)
Q(m) , where the Qs are as described above.
The nonsquare excess measures the difference in the distributions of nonsquares and perfect squares. Values of R(m) greater than one show that more members of T m are nonsquares than would be expected for modulo m. Figure 4 shows the value of R(m) for the first 15,000 values of m. Most notable is the fact that there is a preponderance of R(m) values less than one. This means perfect squares are favored over nonsquares relative to their particular distribution for modulo m. As is true for the saturation and monoid data, there are striations of common values which are clearly visible. The vast majority of the points are concentrated between 0.5 ≤ R ≤ 1.25, though there is a spare population seen for values above around 1.75 and below around 0.4. Another interesting aspect suggested by the data is that as m becomes very large, R is restricted to vales between approximately 0.3 and 2.2. Computation up to m = 700, 000 as was done for saturation is too computationally intensive to investigate numerically using the in-house Python programs used in this work. This remains an open question. Perhaps the most obvious subset of m values to investigate is when m = p is prime. It is well-known that when m is prime the ratio of nonsquares to perfect squares tends to one (see [13], page 128). A plot of R(p) for the primes 5 through 1223 is shown in Figure 5. Interestingly, R(p) shows a pattern according to where p is of the form 8n + 1, 8n + 3, 8n + 5, and 8n + 7. Primes of the form 8n + 1 and 8n + 5 fall into one pattern. These data are shown as red and orange in Figure 5. Primes of the form 8n + 3 (shown in green) and 8n + 7 (shown as blue) form distinct patterns. In all cases, the sequences of primes tend towards R(m) = 1. The sequence given by 8n + 7 does so from above, and the other two sequences do so from below. These data are fit quite well with curves of the form R = p p+x . Specifically, R = p p+2 fits the 8n + 1 and 8n + 5 sequence, R = p p+6 fits the 8n + 3 sequence, and R = p p−2 fits the 8n + 7 sequence. The inset in Figure 5 shows the relative percent error of the fit function to the data.
In general, the telegraph sequence (see [14], pages 211 and 392) can then be discrete-Fourier-transformed to reveal interesting patterns. For primes, the discrete Fourier transform appears nearly random. This is consistent with the notion of perfect squares occurring pseudo-randomly for primes [13]. The example of the 2000th prime, m = 17, 389, is shown in Figure 7. The top left panel shows the discrete Fourier transform of T 17,389 , which is shown as a color-block graph in the middle left panel. This is the direct plot in the complex plane of the discrete Fourier transform. The appearance of these data suggests random structure to how the perfect squares appear in T 17,389 . Blowing up on the scatter plot (top right panel) does reveal some non-random structure, as do the real and imaginary plots (middle and bottom right panels, respectively). The right pointing arrow indicates the further reduction to the set of unique triangular numbers modulo 15. The sequence can then be represented by the block graph of red and blue segments, or as a (network) graph (called G 15 ). This is discussed in Section 8.3. The set of unique triangular numbers modulo 15 is the set of vertices (identified with solid gray arrows), and the pathway through the sequence is the set of edges (identified with dashed gray arrows). Red vertices (edges) indicate perfect squares (a connection between a pair of perfect squares). It is the same for blue but for nonsquares. The purple edges indicate a connection between a perfect square and a nonsquare.
A striking change occurs for the case of prime-squared cases. The example of m = 11 2 = 121 is shown in Figure 8. Now the scatter plot has very distinct structure which arises from the very clear pattern seen in the color-block graph (middle left panel). Several distinct spectral peaks are seen in the absolute spectrum shown in the bottom left panel. These peaks correspond to the lone points in the scatter plot that are far from z = 0. A blow-up of the scatter plot shows a circular pattern of points. These points arise from the baseline of the spectrum which is seen to arc with a modest peak in the middle of the graph.
Further investigation of the interesting circle pattern for the prime-squared case reveals the circle is centered at z = 2 p and has a radius 2 p . Figure 9 shows the cases for primes 3 through 31. There is an additional structure in the points that lie on the circle. Clusters of p − 1 points appear in p sets symmetrically distributed around the circle.   . Further investigation of the structure of the discrete Fourier transform for the cases of m as primes squared for the primes from 3 to 31. The circles of radius 2 p are fits centered at z = 2 p . One notes that p sets of p − 1 points are symmetrically arranged around the circles.

Graph Representation
It is very natural to cast T m in the form of a graph. These graphs can provide a different perspective on the T m that leads to additional insight. Some of this insight will be discussed in this section. While there are several ways one might do this, the current work will adopt the following construction.

Construction of the Graph Representation
Construction 1. Triangular modular graphs, G m (V, E). The vertex set, V, is given by a one-to-one correspondence withT m . The vertex labels are precisely the resides inT m . The undirected edge set, E is given by the path for the first m members of T m .

Structure of the Graph Representation
The structures of the graph are consequences of the theorems regarding T m . Figure 10 show the typical graphs for m = 2 n , m = p where p is prime, and m = p 2 . Both powers of 2 and primes give rise to simple linear paths. Prime-squared cases give rise to "flower" graphs. The structures of these graphs are summarized with the following propositions that follow directly from the structure theorems.

Proposition 7.
Graphs, G m , for m = 2 n where n is a non-negative integer, are simple linear graphs on 2 n vertices.
Proof. The proof follows directly from Theorem 8.
The example of G 8 is shown in Figure 10. Proof. The proof follows directly from Theorems 9 and 10.
The example of G 13 is shown in Figure 10 where one sees a simple linear graph on 7 vertices. Proposition 9. Graphs, G m , for m = p 2 where p is an odd prime, are flower graphs on 1 2 p 2 − p + 2 vertices. The flower has petals which are linear paths of length p − 1 and the stem is of length p−1 2 . Finally, there is one ultimate vertex of degree p that links all the petals and the stem.
Proof. The proof follows directly from Theorem 11.
The example of G p 2 for p = 3, 5, 7, 11 and 13 is shown in Figure 10. Prime powers are very interesting because, in a general sense, the even powers maintain the flower structure and the odd powers maintain the linear structure. Figure 11 shows the cases for p = 5. The left column of the figure shows even powers 2 through 6. One sees that the two petals, one stalk flower structure is maintained while the edges expand into sets of linear subpaths as the power increases. This will be discussed more below. The right column shows the odd powers 3 and 5. Here, the linear structure is maintained with an expansion of edges into linear subpaths as the power increases. Figure 11. Examples of graphs for prime powers, m = 5 a for a ranging from 2 through 6 are shown. The even powers maintain the general shape of the flower graph. The scaling procedure is described in Section 10. The odd powers maintain the general shape of the linear path for the base prime (again, scaling is described in the text). The vertices are referred to using the ultimate, penultimate, and antepenultimate vernacular. For the case of m = p 4 , there is one ultimate vertex of degree p 2 and each petal has p − 1 penultimate vertices. For the case of m = p 6 , there is one ultimate vertex of degree p 4 , and each petal has p − 1 penultimate vertices; between each penultimate vertices there are p − 1 antepenultimate vertices (too small to see in the figure). The odd powers proceed in a similar manner. The graphs are colored according to whether a vertex represents a perfect square (red) or a nonsquare (blue).
Several examples of cases where m is a composite are shown in Figure 12. The top graph shows a highly composite number m = 3 × 5 × 7 × 11× 13 = 15,015. While the graph is complicated, there still remains a hint of net-like structure that is seen in doubly composite numbers, m = p 1 · p 2 , where p 1 and p 2 are odd primes. One example of that type, G 17×31 , is shown in the lower left. An interesting observation about the net-like graphs is that they satisfy the criteria for being planar graphs. There are p 1 −1 2 · p 2 −1 2 internal faces. All but one of these faces are quadrilaterals, with the one exception being a triangle.

Conjecture 5.
Graphs for doubly composite values of m = p 1 · p 2 , where p 1 and p 2 are odd primes, are net-like. That is, there are only vertices of degree 4 (internal to the net) and degree 2 (edge of net) and one vertex of degree 1. The net has p 1 −1 2 · p 2 −1 2 internal faces, precisely one face is a triangle. and the remainder are quadrilaterals.
While outside the scope of this work, we will make one comment on the triangle subgraph. Triangle subgraphs are of interest in network analysis in relation to the "small-world" phenomenon [15]. The graphs associated with T m actually have a dearth of triangle subgraphs. Numerical analysis suggests the following conjecture regarding triangle subgraphs for doubly composite graphs. Conjecture 6. The number of triangle subgraphs for composite graphs, G ∏ n j p j , where the p j are odd primes, is given by the Gaussian binomial coefficients, n − 1 2 2 .

Remark 2.
In general, the Gaussian binomial coefficients (or simply, Gaussian coefficients) are [16], page 36: Finally, powers of two times a prime are shown in the lower right of Figure 12. Multiplication by two, as in G 2×31 , essentially "twins" each vertex. Likewise, multiplication by eight, as in G 8×31 , creates eight vertices out of each one for the corresponding odd prime.
One way to characterize the graphs is by the ratio of the number of edges to the number of vertices. Figure 13 shows |E| |V| for the first 15,000 values of m. Most of the values exceed 1 which is indicative of a more connected graph, although all the graphs are very far from being complete. For powers of 2 and for odd primes, the graphs are simple linear paths which means that the ratio is less than 1 and goes to 1 in the limit of large m.

Perfect Squares and Nonsquares in the Graph Representation
It is particularly enlightening to superimpose the partitioning of T m into perfect squares and nonsquares onto the graph representations. Figure 6 shows this for the case of G 15 . Under modulo m = 15, the perfect squares are 0, 1, 6, and 10 (indicated as red vertices), and 3 and 13 are nonsquares.
Returning to Figure 10 through 12, the graph representation provides additional insight into the nature of the perfect square and nonsquare subsets. First, is it recognized that the ultimate vertex is sometimes a perfect square and sometimes a nonsquare according to the following conjecture.

Conjecture 7.
For m = p where p 2 is an odd prime, then if p = 1 mod 8 or 3 mod 8, the ultimate vertex is a perfect square. Likewise, if p = 5 mod 8 or 7 mod 8, then the ultimate vertex is a nonsquare.
Additionally, the edges of the petals, i.e., p−1 2 and p+1 2 away from the ultimate vertex, are always nonsquares. This is a direct consequence of Theorem 11. Finally, one can state the following conjecture.

Conjecture 8.
Analogous vertices on the petals of G p 2 graphs are of the same type: perfect square or nonsquare.   15,000 (abscissa). Here too, the scatter plot shows striations. While there is a preponderance of ratios that are greater than 1, graphs for m = 2 n and m = p, where p is prime have a ratio that goes to 1 for large m.

Self-Similarity
One method for generating the triangular numbers is to write out the positive integers starting with k = 1 in rows of a table, where the first row contains only one column. Each subsequent row contains one additional column. It is obvious that the right-most entries in such a table will be the triangular numbers. One can now replace each integer in the table by its corresponding value modulo m. Then the rightmost entries are the triangle numbers' moduli m. The three tables below are for m = 4 (left), m = 5 (middle), and m = 6 (right).  4 5 0 1 2 3 4 5 0 1 2 3  4 5 0 1 2 3 4 5 0 1 2 3 4 5 0  1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 The vertical line in these tables demarks the first 2m cycle. The self-similarity of the triangular numbers modulo m is nicely exposed in this arrangement. One quickly notices that if the columns to the left of the vertical line are deleted, the resulting table is identical to the original. Figure 14 is a visual representation of the self-similar nature of the triangular numbers' moduli m. The graph shows the (grayscale normalized) T(k) mod m (horizontal dimension) versus m (vertical dimension). The dark band running from the origin to the point (1000, 500) is the manifestation of the terminal zeros in each cycle. The alternating dark/light band running along the 45 degree line is a manifestation of the odd (zero) and even ( m 2 ) value at the mid-point of the cycle. The repeated pattern appears in the upper-right portion of the graph. One sees a scaling of the visual features seen in the lower-left portion of the graph. Visual representation of the structure of the triangular numbers modulo m for 0 ≤ m < 1000. The vertical axis is the m value and the horizontal axis is the value of T(k) mod m. The scaling structure is seen quite clearly as the eye sweeps from the lower-left corner to the upper-right corner of the plot. Gray represents low values and white represents high values (values normalized by 1/m to show better contrast).

Scaling Properties
The graphical representation of m being a prime power clearly exposes a scaling feature for T p n ←→ T p n+2 This will be explored in this section.

Sprays
The concept of a spray is introduced to aid the study of the scaling properties of the T m graphs. Definition 8. Spray. A set of simple linear paths between two primary vertices. The distinct paths are otherwise identical. That is, they have the same numbers of intermediate vertices and edges, and the degree of the intermediate vertices is exactly two. The paths of a first order spray do not share a vertex. A second-order spray can be thought of as a spray of first order sprays; jth order sprays are sprays of (j − 1)th order sprays. Figure 11 shows an example of sprays as seen in the G 5 3 and G 5 4 graphs. In these cases, one sees that between each primary vertex there are five distinct linear paths, and in each path there are four intermediate second degree vertices. The examples of G 5 5 and G 5 6 show second order sprays, as one sees five sprays emerging from either the ultimate or penultimate vertices. The first order sprays occur between adjacent antepenultimate vertices (and also between an antepenultimate vertex and either an ultimate or penultimate vertex). These feature generalize for all odd primes. The above analysis continues for G p 2n−1 and G p 2n in the obvious way.

Sprays, Renormalization, and Fractal Character
A natural renormalization scheme is provided by the sprays for prime power graphs. If the first order sprays in G p n are replaced by edges, the graph reduces to G p n−2 . In this process, second-order sprays become first order sprays. Likewise, kth order sprays become (k − 1)th order sprays. This process can be repeated until G p n is fully reduced to G p when k is odd and G p 2 when k is even.
The reverse of the renormalization scheme can be performed to scale up a graph from base graphs G p and G p 2 . In this case, each edge is replaced with a spray of p paths; each path has p edges. In a certain sense, this "fractalizes" the graph in that each edge is blown up into a spray indefinitely. As an example, one can consider the scale up from G 5 2 to G 5 4 to G 5 6 seen going down the left side of Figure 11. The ultimate vertex in G 5 2 has five edges emerging from it. These become five groups of five or 5 2 edges in G 5 4 and 5 3 edges in G 5 6 . The other vertices behave similarly. Thus, the act of raising the power on the prime is akin to zooming in on a fractal object.
Some characteristics of the graphs of prime powers can be immediately gleaned from their scaling structures. This leads to two conjectures regarding the graph's diameter and radius. . This does not hold when n is odd and p = 3.
Specific to the even prime powers case, in which the broad scale flower structure is maintained upon scaling, two definitions related to diameter and radius are useful. In those cases, there is a single ultimate vertex. We then define the following. Definition 9. Ultimate distance, u. The distance from a vertex from the ultimate vertex.

Definition 10.
Ultimate radius u r . The maximum distance from the ultimate vertex for a graph.
Consideration of these definitions leads to the following conjecture. Conjecture 11. The ultimate radius and the graph radius are related as u r G p n = r G p n .

Application to Harmonic Analysis
An interesting application of the triangular numbers mod m is the consideration of the lacunary trigonometric function defined on the unit circle in the complex plane, where τ ≡ e iφ [17,18]. The triangular lacunary trigonometric function can be written as a Jacobi theta function (see [19], chapter 16). Writing where the summation is recognized at the second Jacobi theta function (see [19], chapter 16), f n = 1 2 e iπq 8n ϑ 2 0, e iπq 2n .
While the above relation is helpful in putting these triangular lacunary trigonometric systems in a larger mathematical context, it is as interesting to study the sequence of partial summations associated with the lacunary function. The Nth member of the associated finite summation is The 2π periodic nature of e iφ gives rise to T(k) mod 2n. Thus, the machinery of the above theorems can be brought to bear on these functions.
A consequence of Theorem 1 suggests the sequence of finite sums of a given n has 4n-cycles (bounded but not convergent). This suggests that a useful representation of f n is a 4n member sequence that consists of one cycle.
Definition 11. 4n-cycle representation. The 4n-cycle representation of f n is denoted by F n . The auxiliary set of individual terms, e iπT(k) n , is denoted by E n .
While not convergent, one can see that the f n are Cesàro summable and Cesàro converge to zero (see [20], page 96).
A lemma and a theorem regarding f n follow quickly from the theorems in the above sections.
Lemma 4. The jth element of E n has its additive inverse at the 2n + jth element of E n 0 ≤ j ≤ 2n.
Proof. Given that the jth element of E n is e i πT(j) n , the 2n + jth element is e i πT(2n+j) n . Expanding and simplifying the expression leaves one with −e i πT(j) n . This is the additive inverse of the jth term.

Theorem 21.
The sum of the elements of F n is zero.
Proof. From Lemma 4, one notices that each term j in E n will have its additive inverse at the (2n + j)th term. From Theorem 1, one also recognizes the (2n + j)th term =(2n − j)th term. Remembering that F n is a 4n cycle, it is clear to see that the sum of F n will be zero at the 2nth term. Therefore, the jth term will have its additive inverse at the (2n + j)th term. This leads to the summation of all the elements of F n being zero.

Conclusions
This work focused on the structure and properties of the triangular numbers modulo m. The most important aspect of the structure of these numbers is their periodic nature. It was proven that the triangular numbers' moduli m form a 2m-cycle for any m. Additional structural features and properties of this system were presented and discussed. This discussion was aided by various representations of these sequences, such as graphs and through discrete Fourier transformation. The concept of saturation was developed and explored, as were monoid sets and the roles of perfect squares and nonsquares. The triangular numbers' moduli m have self-similarity and scaling features which were briefly discussed as well. It is hoped that this work serves to collect some of the characteristics of the important case of triangular number modulo m.
The story of the triangular number modulo m is far from complete. The numerous conjectures are awaiting proof. Direct numerical analysis and network analysis are certain to provide deeper insight than was presented here. A suggestion from an anonymous reviewer was, "Since the triangular numbers are by definition from all distinct drawings of subsets, a set algorithms refining random generators for order statistics may benefit from the series of triangular numbers modulo m". An potential example here is the Mersenne Twister generator [24,25]. Finally, models of physical phenomena could potentially be found.