Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help with a pascal's triangle program

807606Mar 28 2007 — edited Mar 28 2007
I am trying to write a class that prints out the nth row of pascal's triangle as a string. I need to figure out how to approach the recursive method called "pascalize." I understand the recursive aspect of pascal's triangle... the first two and the last two numbers of each row can be determined without recursion, and then you work your way down to the base case, to determine the rest of the row.

Here's what I have so far:

import java.util.*;

public class pascalsTriangle
{
public static void main (String [] args)
{
Scanner scan = new Scanner (System.in);
System.out.println ("Please enter row of Pascal's Triangle to be printed");
int line = scan.nextInt();
System.out.println (pascalize(line));
}
private static String pascalize ( int num )
{
int[] row = new int[num];
//this is the area i find myself drawing a blank with.

}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 25 2007
Added on Mar 28 2007
2 comments
340 views