Pascal's triangle: Difference between revisions

m
added whitespace before the TOC (Table Of Contents), added a Task (bold) header. split the task's requirement sentences into paragraphs, used a bigger font for the formula to make it easier to read the superscript, replace <= with ≤.
No edit summary
m (added whitespace before the TOC (Table Of Contents), added a Task (bold) header. split the task's requirement sentences into paragraphs, used a bigger font for the formula to make it easier to read the superscript, replace <= with ≤.)
Line 1:
{{task|Arithmetic operations}}
{{task|Arithmetic operations}}[[wp:Pascal's triangle|Pascal's triangle]] is an arithmetic and geometric figure first imagined by [[wp:Blaise Pascal|Blaise Pascal]].
 
Its first few rows look like this:
1
Line 5 ⟶ 7:
1 2 1
1 3 3 1
where each element of each row is either 1 or the sum of the two elements right above it. For example, the next row would be 1 (since the first element of each row doesn't have two elements above it), 4 (1 + 3), 6 (3 + 3), 4 (3 + 1), and 1 (since the last element of each row doesn't have two elements above it). Each row <tt>n</tt> (starting with row 0 at the top) shows the coefficients of the binomial expansion of (x + y)<sup>n</sup>.
 
For example, the next row would be 1 (since the first element of each row doesn't have two elements above it), 4 (1 + 3), 6 (3 + 3), 4 (3 + 1), and 1 (since the last element of each row doesn't have two elements above it).
Write a function that prints out the first n rows of the triangle (with <tt>f(1)</tt> yielding the row consisting of only the element 1). This can be done either by summing elements from the previous rows or using a binary coefficient or combination function. Behavior for <tt>n <= 0</tt> does not need to be uniform, but should be noted.
 
Each row <tt>n</tt> (starting with row 0 at the top) shows the coefficients of the binomial expansion of &nbsp; <big>(x + y)<sup>n</sup></big>.
'''See also:'''
* [[Evaluate binomial coefficients]]
 
 
;Task:
Write a function that prints out the first n rows of the triangle (with <tt>f(1)</tt> yielding the row consisting of only the element 1). This can be done either by summing elements from the previous rows or using a binary coefficient or combination function. Behavior for <tt>n <= 0</tt> does not need to be uniform, but should be noted.
 
This can be done either by summing elements from the previous rows or using a binary coefficient or combination function.
 
Behavior for &nbsp; <tt> n ≤ 0 </tt> &nbsp; does not need to be uniform, but should be noted.
 
 
''';See also:'''
* [[Evaluate binomial coefficients]]
<br><br>
 
=={{header|360 Assembly}}==