Functions are first class objects. Functions establish closures.

Problem: Given a range of positive, non-zero integers, output “Fizz” if the number is evenly divisible by 3, output “Buzz” is the number is evenly divisible by 5, and output “FizzBuzz” if the number is evenly divisible by both 3 and 5; otherwise, output the number.

```
divisor <-
function(number, string) {
function(d) {
if (d %% number == 0) string else ""
}
}
mod3er <- divisor(3, "Fizz")
mod5er <- divisor(5, "Buzz")
fizzbuzz <-
function(i) {
res <- paste0(mod3er(i), mod5er(i))
ifelse(res == "", i, res)
}
sapply(1:100, fizzbuzz)
```