Pascal's Triangle - Divisibility Patterns
misc
Leonid Petrov
Simulation Info
Pascal's Triangle - Divisibility Patterns
misc
Leonid Petrov
This simulation visualizes Pascal’s triangle with dots colored based on whether their values are divisible by a given modulus. This creates interesting fractal-like patterns, especially for prime moduli.
About This Simulation
Pascal’s triangle is a triangular array of numbers where each number is the sum of the two numbers directly above it. This simulation visualizes divisibility patterns by showing dots only where the Pascal’s triangle values are divisible by the chosen modulus.
Controls:
- Mouse/Touch: Drag to pan
- Zoom Buttons: Use “Zoom In” and “Zoom Out” buttons to control zoom level
- Keyboard: Arrow keys (or WASD) to pan, +/- to zoom
- Input Fields: Enter values directly (up to 2000 rows and modulus!)
- Smart View: Changing modulus preserves your current zoom and position
Features:
- Pixel-Perfect Rendering: Uses ImageData for ultra-fast pixel manipulation - no individual dot rendering!
- WebAssembly Optimization: Uses WebAssembly for fast computation of large Pascal triangles (2000+ rows!)
- Mobile-Optimized: Touch controls and responsive design for all devices
- Modular Arithmetic: Uses modular computation from the start to handle large triangles efficiently
- Interactive Controls: Adjust the number of rows and modulus in real-time with instant feedback
Interesting Patterns to Try:
- Modulus 2: Creates the famous Sierpinski triangle fractal
- Modulus 3: Shows a different fractal pattern with three-fold symmetry
- Prime moduli: Generally create self-similar fractal patterns
- Composite moduli: Create more complex, often less regular patterns
The patterns emerge from the properties of binomial coefficients and modular arithmetic, revealing deep mathematical structures within Pascal’s triangle.
code
(note: parameters in the code might differ from the ones in
simulation results below)
-
Link to code
(This simulation is interactive, written in JavaScript with WebAssembly optimization, see the source code of this page at the link)
Dear colleagues:
Feel free to use code (unless otherwise specified next to the corresponding link),
data, and visualizations to illustrate your research in talks and papers,
with attribution (
CC BY-SA 4.0).
Some images are available in very high resolution upon request.
I can also produce other simulations upon request - email me at
lenia.petrov@gmail.com
This material is based upon work supported by the National Science Foundation under Grant DMS-2153869