Results 1 to 7 of 7
Thread: Pascals Triangle
- 12-09-2010, 09:53 PM #1
Senior Member
- Join Date
- Oct 2010
- Location
- Newark,nj
- Posts
- 111
- Rep Power
- 0
- 12-10-2010, 12:13 AM #2
Work it out on paper. Pick a number (like 5 or 6), and draw every line of Pascal's Triangle up to that point. Then think about how you determined each line in your head. Think about the criteria you use to determine which numbers would go in which order.
- 12-10-2010, 02:48 AM #3
Senior Member
- Join Date
- Feb 2010
- Location
- Waterford, Ireland
- Posts
- 748
- Rep Power
- 4
Or to help out those who do not know post a description of what Pascal's Triangles are...so we can help you programmatically (is that a word :D)
- 12-10-2010, 05:37 AM #4
Silly guy--never took math!? =) Clicky.
The numbers are based on binomial theorem; it is formulated as such, and procedurally generated by adding adjacent numbers for the row below.
- 12-10-2010, 05:10 PM #5
Senior Member
- Join Date
- Oct 2010
- Location
- Newark,nj
- Posts
- 111
- Rep Power
- 0
Hey guys thanks for the responses i've been away so i couldnt reply..UGGHH.. ok so i've wrote a little bit of code but im basically shooting in the dark ..heres what i have so far..Code has some english in it so please dont critique TOO MUCH , im trying.
i will start over if suggested if this code is completly bogus, i know its a mathematical pattern but im having trouble with all the loops and dont no if i should just use an array..i need to code this and understand it before my final pretty sure its going to be on there..using recursion...THANKS MATESJava Code:public class Pascal { public static void main(String[] args) { Pascal p=new Pascal(); int row=10; for(int x=0;x<=row;x++){ for(int y=0;y<=x;y++){ System.out.print(p.pascal(x, y)+" "); System.out.println(); } } } int pascal(int x,int y) { if(x=1 || x=y || y=0){ } else{ return pascal(x-1,y-1)+pascal(x-1,y); } } } //int x=row; //int y=col;
- 12-10-2010, 06:57 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
Suppose you have the values for n-1, say, 1, 3, 3, 1. For the values for row n all you have to do is add all (left) consecutive values from the right: 1, 4, 6, 4 and add another value 1 to the right: 1, 4, 6, 4, 1. For n == 0 you have the value 1 and you don't need to know more.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 12-16-2010, 12:22 AM #7
Senior Member
- Join Date
- Feb 2010
- Location
- Waterford, Ireland
- Posts
- 748
- Rep Power
- 4
Similar Threads
-
triangle
By Shyamz1 in forum New To JavaReplies: 4Last Post: 11-07-2010, 06:12 PM -
Triangle using Numbers
By Anandt88 in forum New To JavaReplies: 16Last Post: 06-05-2010, 04:10 PM -
ASCII Triangle
By physics in forum New To JavaReplies: 2Last Post: 03-13-2010, 01:00 AM -
Pascals triangle through recursion
By hedonist in forum New To JavaReplies: 3Last Post: 08-03-2009, 07:45 PM -
Triangle
By jkswebsite in forum New To JavaReplies: 8Last Post: 01-10-2009, 02:08 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks