Pascal's triangle - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: Pascal's triangle (/thread-4610.html) Pascal's triangle - roadrunner - 09-01-2015 01:11 PM Function pascal(x) returns a level of Pascal's triangle. Example: pascal(7) returns {1,7,21,35,35,21,7,1} the 7th level of Pascal's triangle Code: ```#pragma mode(separator(.,;) integer(h32)) EXPORT pascal(x) BEGIN  case   if x < 1 then {1};end;   if x < 2 then {1,1}; end;  default   concat(1,execon("&1+&2",pascal(x−1)),1);  end; END;``` RE: Pascal's triangle - Gerald H - 09-01-2015 04:30 PM Isn't {1,7,21,35,35,21,7,1} the 8th line? RE: Pascal's triangle - roadrunner - 09-02-2015 01:15 AM (09-01-2015 04:30 PM)Gerald H Wrote:  Isn't {1,7,21,35,35,21,7,1} the 8th line? Here: http://ptri1.tripod.com/ they start counting with row zero, making {1,7,21,35,35,21,7,1} row 7. But Blaise Pascal himself, it seems, would have agreed with you: https://en.wikipedia.org/wiki/Pascal%27s_triangle#/media/File:TrianguloPascal.jpg -road RE: Pascal's triangle - Joe Horn - 09-02-2015 02:58 PM Alternative method, using a single expression: pcoeff(makemat(-1,j,1)) --> jth row of Pascal's Triangle Works both in Home and CAS.