```ruby
<<~DOC
  Use reduce to get the sum of an array
DOC

a = [1, 2, 3]
a.reduce :+ # => 6
```

Use reduce to compute factorials
user
```ruby
# Use reduce to get the sum of an array
a = [1, 2, 3]
a.reduce :+ # => 6

# Use reduce to get the factorial of a number
(1..n).reduce(1, :*)
```
assistant