## Triangular Squares

In a recent video Matt Parker showed a triangular number that also is a square number, 6, and asked if there were more.

A triangular number has the form $\frac{n^2+n}{2}$ — shown by Euler — and a square number has the form $m^2$.
Triangular squares are those numbers for which $\frac{n^2+n}{2} = m^2$ with $n,m \in \mathbb{N}$.
Examples are $\{0, 1, 6, 35, 204, 1189, 6930, \dots\}$ (sequence A001109 in OEIS).

To check if triangular numbers are square numbers is easy (code listed below), but a mathematical function would be nicer.
The first thing I tried was to define the triangular number’s square root as a whole number, $\sqrt{\frac{n^2+n}{2}} = \lfloor \sqrt{\frac{n^2+n}{2}} \rfloor$. This function does not return the square numbers that are triangular but the triangular numbers that are square.
The resulting sequence is $\{0, 1, 8, 49, 288, 1681, 9800, \dots\}$ (sequence A001108 in OEIS).

# Python 2.7.7 Code
# Jonathan Frech 13th of July, 2016
#         edited 15th of July, 2016
Advertisements

## Sierpinski TIrangle

Using the same method used in my previous Sierpinski Triangle program, which is written in Python, I wrote a fractal generator for my graphing calculator TI-84 Plus in BASIC.

"// TI-84 Plus BASIC Code"
"// Jonathan Frech 25th of April, 2016"
"//         edited 21st of May  , 2016"

## Pascal’s Triangle

Pascal’s triangle is an interesting mathematical sequence. It is often written as a triangle, starting with $\{1\}$, then $\{1, 1\}$. To generate the next row, you add the two numbers above to form another one. So the next row in the sequence is $\{1, 2, 1\}$ then $\{1, 3, 3, 1\}$, $\{1, 4, 6, 4, 1\}$ and so on (sequence A007318 in OEIS).

One interesting property of Pascal’s triangle is the generation of binomials.
To calculate $(a + b)^4$, you can look at the 4th row (listed above and when starting to count at $0$) and determine
$(a + b)^4 = (1 \cdot a^4 \cdot b^0) + (4 \cdot a^3 \cdot b^1) + (6 \cdot a^2 \cdot b^2) + (4 \cdot a^1 \cdot b^3) + (1 \cdot a^0 \cdot b^4)$
$(a + b)^4 = a^4 + 4a^3b + 6a^2b^2 + 4ab^3 + b^4$.

This program generates Pascal’s sequence in a rather unusual shape, looking a bit like a crown.

To get more information about Pascal’s triangle, check out this Wikipedia entry.

#### Controls

• F1 advances the sequence
• Space takes a screenshot

# Python 2.7.7 Code
# Pygame 1.9.1 (for Python 2.7.7)
# Jonathan Frech 25th of March, 2016