[CHALLANGE] Pascal Triangle | Sololearn: Learn to code for FREE!

+25

[CHALLANGE] Pascal Triangle

Input(number of rows) = 6 output: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 Create a program which will make such triangle 1>Using Arrays 2>Without using Arrays Good Luck :)

10/29/2017 10:38:19 AM

Mr. Bot

14 Answers

New Answer

+3

My two solutions. The two versions use the same formatting which allows for only 3 digit numbers and therefore loses its neatness when n exceeds 12. It still works. Using an array: https://code.sololearn.com/cBXDN7k81y0B/#java Without using an array. https://code.sololearn.com/c2l37lxXhPfr/#java

+26

here is my try // using both arrays and loops ☺ https://code.sololearn.com/c5g3Qt9Lqt5e/?ref=app

+14

https://code.sololearn.com/c2x6b0H46PM7/?ref=app

+9

two lines ... lazy https://code.sololearn.com/cVifR0ybhcNu/?ref=app

+9

My try, without arrays https://code.sololearn.com/cGbf57Un3bXu/?ref=app

+8

Javascript: https://code.sololearn.com/Wb4ZMiceHBs6/?ref=app

+6

my java try https://code.sololearn.com/cGO8bXczaL6l/?ref=app

+5

Here is mine using arrays: https://code.sololearn.com/cAuablJG3TRE

+4

https://code.sololearn.com/cRcxtbrhK28D/?ref=app

+4

w/o arrays in c++ edit: w/ arrays in c++ edit: added a progarm with out using the x Choose y method. fixed both progarms, after re-reading challange. The Pascal Triangle row 0=1 and row 1 =1,1 yet the input is number of rows to print out including row 0, so I fixed my code to run the way the challange specified. https://code.sololearn.com/c2s4HEGHEX9S/?ref=app https://code.sololearn.com/c17F372suu6t/?ref=app https://code.sololearn.com/cvSEYEauGohr/?ref=app

+3

for our webdesigner: if the even numbers get a different color the the odds... and the triangle is very big.... there is a wonderful pattern. for easiness dont print the numbers but different clored stars, depending on odd or even.

+3

Happy New Year to all. Here is my try https://code.sololearn.com/cAGqE8084Fh9/?ref=app

+2

Finally coded the non-array version. https://code.sololearn.com/c3b9ROBU06Z2/?ref=app

+2

when building, two lists are used: 1 - previous half-line of the triangle 2 - current half-line of the triangle The values of the central snake axis of a triangle are always one first element of the list. Additionally, the power of two is calculated as the sum of the elements of the line of the triangle, but according to the list of the current semi-line. Additionally calculated https://code.sololearn.com/WHcElo6SdLdU/?ref=app