public class PascalTriangle { public static int [] [] pascalTriangle (int n) { int [][] pt = new int [n][]; for (int i = 0; i < n; i++){ pt[i] = new int [i + 1]; pt[i][0] = 1; for (int j = 1; j < i; j++) { pt[i][j] = pt[i - 1][j - 1] + pt [i -1][j]; } pt[i][i] = 1; } return pt; } public static void printTriangle (int x [][], int n) { for (int i = 0; i < n; i++){ System.out.println(); for (int k = 0; k <= i; k++ ) { System.out.print (" " + x[i][k]); } } } public static void getPascalTriangle (int n) { printTriangle (pascalTriangle (n), n); } public static void main(String[] args) { int G = 30; getPascalTriangle(G); } }
Tuesday, October 9, 2007
PascalTriangles once more!
Here we go again...Pascal Triangles once more...by popular demand only....
Subscribe to:
Post Comments (Atom)
Just some daily notes ...
Things I'm into now...
Blog Archive
-
▼
2007
(29)
-
▼
October
(15)
- Deconstructing a Scheme recursive function and imp...
- Anasi Boys
- Iterator for Collection and Nested Class
- The Uninvited!
- Inheritence and PolyMorphIsm
- Iterator Example
- Java Library ArrayList
- Inserting into an array non-destructively
- Singly linked list operations...
- PascalTriangles once more!
- Sieve of Erotosthenes
- Linked List Constructor Functionality Testing
- The Linked List Maker method
- Simple Linked List operations
- Old blogs before Day 0.
-
▼
October
(15)
No comments:
Post a Comment