Skip to content

Commit

Permalink
Add a floor function to factorial example
Browse files Browse the repository at this point in the history
  • Loading branch information
misalcedo authored Jan 5, 2022
1 parent 9df8c6d commit 0218699
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/src/factorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ In this chapter we will implement [factorial](https://en.wikipedia.org/wiki/Fact
Create a file named `factorial.ta` with the following contents:

```tortuga
@round(@n) = round(n, n % 1)
@round(@n, @remainder >= 0.5) = 1 + n - (n % 1)
@round(@n, @remainder < 0.5) = n - (n % 1)
@floor(@n) = n - (n % 1)
@round(@n) = round(floor(n), n % 1)
@round(@n, @remainder >= 0.5) = 1 + n
@round(@n, @remainder < 0.5) = n
@factorial(@n = 0) = 1
@factorial(@n > 0) = [
Expand Down

0 comments on commit 0218699

Please sign in to comment.