Answer to Question #271640 in Java | JSP | JSF for yyyyyy

Question #271640

Solution in java ONLY plz... FULL question can be found on the following link http://ntci.on.ca/compsci/java/ch5/5_9.html ---> question 14

I cannot put full question here as its too long... so full question is on the link

The requirement is for it to NOT be done with import java.io.*; etc..... just directly

Thanks, appreciate it

----------------------------------------------------------------------------------

Write a program that prints portions of Pascal's triangle. The program should repeatedly ask the user to supply the number of rows in the triangle, terminating when the user supplies the value zero. In printing a triangle, the first value in the last row should appear in the first column and each preceding row should start printing three spaces further right........


1
Expert's answer
2021-11-26T07:07:57-0500


class Main {
	public static int fact(int i)
	{
		if (i == 0)
			return 1;
		return i * fact(i - 1);
	}
	public static void main(String[] args)
	{
		int n = 4;
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= n - i; j++) {
				System.out.print(" ");
			}
			for (int j = 0; j <= i; j++) {
				System.out.print(" "+ fact(i)/ (fact(i - j)* fact(j)));
			}
			System.out.println();
		}
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Gous
09.12.21, 19:33

Really appreciate your help!!!!!!!!!!!!!!!!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS