Skip to content

Commit e296242

Browse files
authored
Merge pull request #337 from habibasorour/issue_327_math
Issue 327 fixed: fix math formatting in 7.1
2 parents 922c4c9 + 0045755 commit e296242

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

source/ch7_recursion.ptx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@
1414
</p>
1515

1616
<p>
17-
Let's take the familiar factorial function, which calculates <m>n!</m> (read as "n factorial"), so for example 5! = 5 × 4 × 3 × 2 × 1 = 120. Factorial is a classic example of recursion, where the function calls itself with a smaller value until it reaches a base case.
18-
In general, <m>n! = n \times (n-1) \times (n-2) \times \cdots \times 2 \times 1</m>,
19-
or recursively defined as <m>n! = n \times (n-1)!</m> with base cases <m>0! = 1</m> and <m>1! = 1</m>.
17+
Let's take the familiar factorial function, which calculates <m>n!</m> (read as "n factorial"), so for example <md> 5! = 5 × 4 × 3 × 2 × 1 = 120.</md> Factorial is a classic example of recursion, where the function calls itself with a smaller value until it reaches a base case.
18+
In general, <md>n! = n \times (n-1) \times (n-2) \times \cdots \times 2 \times 1</md>,
19+
or recursively defined as <md>n! = n \times (n-1)!</md> with base cases <m>0! = 1</m> and <m>1! = 1</m>.
2020
</p>
2121
<p>
2222
You may recall mathematical notation using the symbol <m>\sum</m> (Greek letter sigma)
2323
to represent "sum." For example, when we sum all elements in an array, we write
24-
<m>\sum_{i=0}^{n-1} a_i</m>, where <m>i=0</m> below the symbol indicates we start at index 0,
24+
<md>\sum_{i=0}^{n-1} a_i</md>, where <m>i=0</m> below the symbol indicates we start at index 0,
2525
<m>n-1</m> above it means we end at index <m>n-1</m>, and <m>a_i</m> represents the array
26-
element at each index <m>i</m>. Similarly, <m>\sum_{i=1}^{n} i</m> means "sum all integers
26+
element at each index <m>i</m>. Similarly, <md>\sum_{i=1}^{n} i</md> means "sum all integers
2727
<m>i</m> from 1 to <m>n</m>."
2828
</p>
2929
<p>
3030
Factorial involves multiplication rather than addition, so we use the product symbol
31-
<m>\prod</m> (Greek letter pi): <m>n! = \prod_{i=1}^{n} i</m>, which means "multiply
31+
<m>\prod</m> (Greek letter pi): <md>n! = \prod_{i=1}^{n} i</md>, which means "multiply
3232
all integers <m>i</m> from 1 to <m>n</m>." Both summation and factorial can be expressed
3333
recursively—summation as the first element plus the sum of remaining elements, and factorial
34-
as <m>n \times (n-1)!</m>.
34+
as <md>n \times (n-1)!</md>.
3535
</p>
3636
<p>
3737
Here is a Python implementation of factorial using just one function:

0 commit comments

Comments
 (0)