Java code for Printing Pascal Triangle

preview_player
Показать описание
This program demonstrates the logic and code for Printing Pascal Triangle. Pascal Triangle prints the numbers in the following order
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1

This program gives hands on nested for loops.

If you like this video, don't forget to subscribe , like and share this video

Please promote this channel , by sharing it with your friends who are searching / preparing for IT jobs in programming..

If you have any coding challenges ( questions ) , post them in the comment, we will upload the videos for the same
Рекомендации по теме
Комментарии
Автор

After searching a lot I find trigular format solution here. I implemented the same thing in scala. Appreciate your help. Thanks!

dmdeepakmittal
Автор

I spent three days in finding a better understandable solution of pascal triangle finally i got this video

abhaykumar
Автор

class Solution(object):
def generate(self, numRows):

my_list=[]
prev_list=[]
prev_list.append(1)

if numRows==1:
return [prev_list]
else:
for i in range(0, numRows):
list1=[]

for j in range(0, i):
if j==0:
list1.append(1)
else:




list1.append(1)
prev_list=list1
my_list.append(list1)
return my_list
try this

ramkrishnak
Автор

Thank You i learned too much with your help.

luismiguelhurtadoarias
Автор

THANK YOU SIR, RESPECT! now i can do my assignment :') keep it up!

nizharfan
Автор

Sir I can clearly understand ur teaching please explain some more topics...

sarithareddy
Автор

Plz make a video on reverse a full sentence word by word eg. Sky is blue to blue is sky in java plz .. ..make a video on it

blackrose
Автор

i don, t understand how the equation i-j/i+j work beacaue i and j increment at the time

nadaayman
Автор

but the doubt over here is you are incrementing the spaces in every traversal as well as decrementing it then how come it may give you a proper triangle order?

CSSANJAYR
Автор

It wont display properly when numbers get to 3 digit length but nice compact solution

SuperICHmagdich
Автор

in the first iteration i and j both are zero th number should be zer
o

prvizpirizaditweb
Автор

I have little bit of problem with this formula. Actually it's against the standard and conventional programming. Because it has spilled values. when you have j=2 and i = 3
your formula turns out number = number * (3-2)/(2+1)
==> number = number * (1)/(3)
==> number = number * 0.33
though int/int show integer value 0.. this is against a good programming.

shahriarmim
Автор

Can you do 2D array for the same example

gameskingdom