Overview
The Pascal's Triangle Explorer generates rows of Pascal's Triangle and analyzes patterns, including Singmaster's Conjecture about how many times numbers appear. All calculations are performed using Romasm assembly.
Pascal's Triangle
What is it?
Pascal's Triangle is a triangular array where each number is the sum of the two numbers directly above it. The first few rows:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
The entry at row n, column k (0-indexed) is the binomial coefficient C(n,k) = n!/(k!(n-k)!).
Singmaster's Conjecture: How many times does a given number appear in Pascal's Triangle? It's conjectured that most numbers appear only a few times, with exceptions like 1, 2, 3, etc.
Romasm Implementation
The explorer uses Romasm assembly to calculate binomial coefficients:
; Calculate binomial coefficient C(n, k)
; Input: R0 = n, R1 = k
; Output: R0 = C(n, k) = n! / (k! * (n-k)!)
; Calculate n!
LOAD R2, R0
CALL factorial ; R0 = n!
; Calculate k!
LOAD R2, R1
CALL factorial ; R0 = k!
LOAD R3, R0 ; Store k! in R3
; Calculate (n-k)!
LOAD R2, R0 ; R2 = n
SUB R2, R1 ; R2 = n - k
LOAD R0, R2
CALL factorial ; R0 = (n-k)!
; Multiply k! * (n-k)!
MUL R0, R3 ; R0 = k! * (n-k)!
; Divide n! by (k! * (n-k)!)
LOAD R2, R0 ; R2 = n!
LOAD R0, R2
DIV R0, R3 ; R0 = n! / (k! * (n-k)!)
RET
Using the Explorer
- Enter the number of rows to generate
- Click "Generate Triangle"
- View the triangle displayed
- Analyze patterns and count number occurrences
Related Documentation
- Math Library - Factorial function
- Try the Explorer - Open it now!