samedi 4 juin 2016

How to print Pascal Triangle in Java - Example Tutorial

Printing patterns with stars or numbers and triangles are some of the the common programming exercises. Earlier we have seen how to print pyramid pattern with stars and today you will learn how to print Pascal's triangle in Java. Sometime this problem is also asked as "write a program to print Pascal triangle without using array" or by just using for loop. Pascal’s triangle is a set of numbers arranged in the form of a triangle, similar to Floyd's triangle but their shape is different. Each number in the Pascal triangle row is the sum of the left number and right number of the previous row. If a number is missing in the above row,  it is assumed to be 0. The first row starts with number 1, that's why you will see that first two row of Pascal triangle just contain 1.
Read more »
Share:

0 commentaires:

Enregistrer un commentaire