The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
Pascal's triangle
09-01-2015, 01:11 PM (This post was last modified: 09-01-2015 01:36 PM by roadrunner.)
Post: #1
Pascal's triangle
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;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Pascal's triangle - roadrunner - 09-01-2015 01:11 PM
RE: Pascal's triangle - Gerald H - 09-01-2015, 04:30 PM
RE: Pascal's triangle - roadrunner - 09-02-2015, 01:15 AM
RE: Pascal's triangle - Joe Horn - 09-02-2015, 02:58 PM



User(s) browsing this thread: 1 Guest(s)