Notes on triangular and square numbers.

c-declarations
Joshua Potter 2024-03-02 16:37:08 -07:00
parent d27412d5c7
commit aff3dbf43d
9 changed files with 417 additions and 5 deletions

View File

@ -88,7 +88,10 @@
"ordering-repetition.jpg",
"ordering-y-repetition-n.jpg",
"ordering-n-repetition-y.jpg",
"ordering-n-repetition-n.jpg"
"ordering-n-repetition-n.jpg",
"triangular-gnomon.png",
"pascals-triangle.webp",
"square-gnomon.png"
],
"File Hashes": {
"algorithms/index.md": "cd7c7ba91fb2f961c9f2437777e8e2ac",
@ -219,13 +222,17 @@
"filesystems/cas.md": "34906013a2a60fe5ee0e31809b4838aa",
"git/objects.md": "b95228a78744d3f9fe173e575aa0445a",
"git/index.md": "83d2d95fc549d9e8436946c7bd058d15",
"encoding/integer.md": "5dd3a961bf259e53da207209051b8335",
"encoding/integer.md": "3107074a5070670f2f8fab17abc05fbb",
"_journal/2024-02-29.md": "f610f3caed659c1de3eed5f226cab508",
"_journal/2024-02/2024-02-28.md": "7489377c014a2ff3c535d581961b5b82",
"_journal/2024-03-01.md": "a532486279190b0c12954966cbf8c3fe",
"_journal/2024-02/2024-02-29.md": "0e502a2c8baf90c2f12859b03f10b5a1",
"algebra/sequences.md": "97c217823aacf8910a1a37bde694ecfe",
"algebra/sequences/index.md": "e5a7cdfbcb61709ce2963c4b5e53a8f2"
"algebra/sequences/index.md": "e5a7cdfbcb61709ce2963c4b5e53a8f2",
"_journal/2024-03-02.md": "08c3cae1df0079293b47e1e9556f1ce1",
"_journal/2024-03/2024-03-01.md": "70da812300f284df72718dd32fc39322",
"algebra/sequences/triangular-numbers.md": "18925b0ecae151c3e6d38bc018c632c4",
"algebra/sequences/square-numbers.md": "886fb22fb8dbfffdd2cd233558ea3424"
},
"fields_dict": {
"Basic": [

View File

@ -0,0 +1,13 @@
---
title: "2024-03-02"
---
- [x] Anki Flashcards
- [x] KoL
- [ ] Sheet Music (10 min.)
- [ ] Go (1 Life & Death Problem)
- [ ] Korean (Read 1 Story)
- [ ] Interview Prep (1 Practice Problem)
- [ ] Log Work Hours (Max 3 hours)
* Notes on triangular and square numbers.

View File

@ -8,7 +8,7 @@ title: "2024-03-01"
- [ ] Go (1 Life & Death Problem)
- [ ] Korean (Read 1 Story)
- [ ] Interview Prep (1 Practice Problem)
- [ ] Log Work Hours (Max 3 hours)
- [x] Log Work Hours (Max 3 hours)
* Reviewed database reading/videos from yesterday with Kevin.
* Finished planning soft skills course with Gus.

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -0,0 +1,132 @@
---
title: Square Numbers
TARGET DECK: Obsidian::STEM
FILE TAGS: algebra::sequence
tags:
- algebra
- sequence
---
## Overview
The $n$th term of the **square numbers** $(s_n)_{n \geq 0}$ is $n^2$. The first few terms are $$0, 1, 4, 9, 16, 25, 36, 49, 64, \ldots$$
%%ANKI
Basic
What shape do gnomons associated with square numbers take on?
Back: L-shapes.
Reference: “Square Number,” in _Wikipedia_, May 10, 2023, [https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731](https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731).
<!--ID: 1709422558613-->
END%%
%%ANKI
Basic
How are gnomons of the square numbers visualized?
Back:
![[square-gnomon.png]]
Reference: “Square Number,” in _Wikipedia_, May 10, 2023, [https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731](https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731).
<!--ID: 1709422558619-->
END%%
%%ANKI
Basic
What general term refers to the different colored segments in the following?
![[square-gnomon.png]]
Back: Gnomons.
Reference: “Square Number,” in _Wikipedia_, May 10, 2023, [https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731](https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731).
<!--ID: 1709422558622-->
END%%
%%ANKI
Basic
What are the first five square numbers $(s_n)_{n \geq 0}$?
Back: $0, 1, 4, 9, 16$
Reference: “Square Number,” in _Wikipedia_, May 10, 2023, [https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731](https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731).
<!--ID: 1709422558625-->
END%%
%%ANKI
Basic
How is square number $16$ graphically depicted?
Back:
```
* * * *
* * * *
* * * *
* * * *
```
Reference: “Square Number,” in _Wikipedia_, May 10, 2023, [https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731](https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731).
<!--ID: 1709422558628-->
END%%
%%ANKI
Basic
What closed formula is used to find the $n$th square number?
Back: $n^2$
Reference: “Square Number,” in _Wikipedia_, May 10, 2023, [https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731](https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731).
<!--ID: 1709422558631-->
END%%
%%ANKI
Basic
What is the recurrence relation in the recursive definition of square numbers $(s_n)_{n \geq 0}$?
Back: $s_n = s_{n-1} + (2n - 1)$
Reference: “Square Number,” in _Wikipedia_, May 10, 2023, [https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731](https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731).
<!--ID: 1709422558634-->
END%%
%%ANKI
What is the initial condition(s) in the recursive definition of square numbers $(s_n)_{n \geq 0}$?
Back: $s_0 = 0$
Reference: “Square Number,” in _Wikipedia_, May 10, 2023, [https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731](https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731).
END%%
%%ANKI
Basic
How is the $n$th square number $s_n$ represented with sigma notation?
Back: $s_n = \sum_{k=1}^n (2k - 1)$
Reference: “Square Number,” in _Wikipedia_, May 10, 2023, [https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731](https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731).
<!--ID: 1709422558638-->
END%%
%%ANKI
Basic
Which polygonal numbers are the "next" generalization of triangular numbers?
Back: The square numbers.
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325898-->
END%%
%%ANKI
Cloze
The sum of {1:natural numbers} is to {2:triangular numbers} whereas the sum of {2:odd natural numbers} is to {1:square numbers}.
Reference: “Square Number,” in _Wikipedia_, May 10, 2023, [https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731](https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731).
<!--ID: 1709422558641-->
END%%
%%ANKI
Basic
What polygonal number is $k$ equal to after the following `for` loops?
```c
int k = 0;
for (int i = 1; i <= n; ++i) {
k += 2 * i - 1;
}
```
Back: The $n$th square number.
Reference: “Square Number,” in _Wikipedia_, May 10, 2023, [https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731](https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731).
<!--ID: 1709422558645-->
END%%
%%ANKI
Basic
*Why* are square numbers a sum of odd numbers?
Back: The gnomon of a square number is twice the width of the previous square, plus the corner.
Reference: “Square Number,” in _Wikipedia_, May 10, 2023, [https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731](https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731).
<!--ID: 1709422558648-->
END%%
## References
* Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
* “Square Number,” in _Wikipedia_, May 10, 2023, [https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731](https://en.wikipedia.org/w/index.php?title=Square_number&oldid=1154182731).

View File

@ -0,0 +1,260 @@
---
title: Triangular Numbers
TARGET DECK: Obsidian::STEM
FILE TAGS: algebra::sequence
tags:
- algebra
- sequence
---
## Overview
The $n$th term of the **triangular numbers** $(T_n)_{n \geq 0}$ is the sum of whole numbers $\sum_{k=0}^n k$. The first few terms are $$0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, \ldots$$
%%ANKI
Basic
What is a polygonal number?
Back: A number of pebbles that can be arranged into the shape of a regular polygon.
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325851-->
END%%
%%ANKI
Basic
What is a figurate number?
Back: Polygonal numbers or generalizations of polygonal numbers to other dimensions.
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325856-->
END%%
%%ANKI
Basic
What are considered the simplest polygonal numbers?
Back: The triangular numbers.
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325859-->
END%%
%%ANKI
Basic
How do polygonal numbers relate to figurate numbers?
Back: Polygonal numbers are a subset of the figurate numbers.
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325862-->
END%%
%%ANKI
Basic
What is a gnomon?
Back: The "piece" added to a figurate number to transform it to the next larger one.
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325865-->
END%%
%%ANKI
Basic
What shape do gnomons associated with triangular numbers take on?
Back: Lines.
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325874-->
END%%
%%ANKI
Basic
How are gnomons of the triangular numbers visualized?
Back:
![[triangular-gnomon.png]]
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325878-->
END%%
%%ANKI
Basic
What general term refers to the highlighted portion of pebbles in the following?
![[triangular-gnomon.png]]
Back: Gnomons.
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325883-->
END%%
%%ANKI
Basic
The triangular numbers correspond to what kind of triangles?
Back: Equilateral triangles.
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325887-->
END%%
%%ANKI
Basic
What is the first triangular *and* square number?
Back: $36$
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325891-->
END%%
%%ANKI
Basic
What are the first five triangular numbers $(T_n)_{n \geq 0}$?
Back: $0, 1, 3, 6, 10$
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325904-->
END%%
%%ANKI
Basic
How is triangular number $10$ graphically depicted?
Back:
```
*
* *
* * *
* * * *
```
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325909-->
END%%
%%ANKI
Basic
Algebraically speaking, *what* is the $n$th triangular number?
Back: $\sum_{k=1}^n k$.
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325914-->
END%%
%%ANKI
Basic
What polygonal sequence is the summation analogue of factorial?
Back: The triangular numbers.
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325918-->
END%%
%%ANKI
Basic
What notation does Knuth introduce to denote the $n$th triangular number?
Back: $n?$
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325922-->
END%%
%%ANKI
Basic
What name does Knuth give the LHS of $n? = \sum_{k=1}^n k$?
Back: The termial.
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325927-->
END%%
%%ANKI
Cloze
The {1:term}ial is to {2:$n?$} as the {2:factor}ial is to {1:$n!$}.
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325931-->
END%%
%%ANKI
Basic
What closed formula is traditionally used to compute the $n$th triangular number?
Back: $\frac{n(n + 1)}{2}$
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325936-->
END%%
%%ANKI
Basic
What is the recurrence relation in the recursive definition of triangular numbers $(T_n)_{n \geq 0}$?
Back: $T_n = T_{n-1} + n$
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709422558652-->
END%%
%%ANKI
Basic
What is the initial condition(s) in the recursive definition of triangular numbers $(T_n)_{n \geq 0}$?
Back: $T_0 = 0$
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709422558656-->
END%%
%%ANKI
Basic
How do you expand sum $\sum_{k=1}^n k$ to derive closed formula $\frac{n(n + 1)}{2}$?
Back:
$$\begin{matrix}
1 & + & 2 & + & \cdots & + & n \\
n & + & (n - 1) & + & \cdots & + & 1 \\
\hline
(n + 1) & + & (n + 1) & + & \cdots & + & (n + 1)
\end{matrix}$$
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
<!--ID: 1709419325942-->
END%%
%%ANKI
Basic
What combinatorial closed formula is used to compute the $n$th triangular number?
Back: $\binom{n + 1}{2}$
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325949-->
END%%
%%ANKI
Basic
What is the combinatorial explanation as to why the $n$th triangular number is $\binom{n + 1}{2}$?
Back: $\sum_{k=1}^n k$ is the number of ways distinct pairs can be made from $n + 1$ objects.
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325956-->
END%%
%%ANKI
Basic
Where in Pascal's triangle are the natural numbers embedded?
Back: Along the second leftward diagonal:
![[pascals-triangle.webp]]
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325963-->
END%%
%%ANKI
Basic
Where in Pascal's triangle are the triangular numbers embedded?
Back: Along the third leftward diagonal:
![[pascals-triangle.webp]]
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325970-->
END%%
%%ANKI
Basic
What polygonal number is $k$ equal to after the following `for` loops?
```c
int k = 0;
for (int i = 1; i <= n; ++i) {
k += i;
}
```
Back: The $n$th triangular number.
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325976-->
END%%
%%ANKI
Basic
Why is $n(n + 1)$ geometrically significant w.r.t. the $n$th triangular number?
Back: $2 \cdot T_n$ is the number of units in an $n \times (n + 1)$ rectangle, e.g.
```
* * * * -
* * * - -
* * - - -
* - - - -
```
Reference: “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).
<!--ID: 1709419325981-->
END%%
## References
* Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
* “Triangular Number,” in _Wikipedia_, January 13, 2024, [https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122](https://en.wikipedia.org/w/index.php?title=Triangular_number&oldid=1195279122).

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -949,7 +949,7 @@ END%%
%%ANKI
Basic
Why should you generally prefer `x < y` over `x - y < 0`?
Back: The former avoids possible underflows.
Back: The former avoids possible overflows.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1708799678725-->
END%%