# PERM: Enumerating Gene Orders

A permutation of length is an ordering of the positive integers . For example, is a permutation of length 55.

Given: A positive integer .

Return: The total number of permutations of length , followed by a list of all such permutations (in any order).

## Sample Dataset

```
3
```

## Sample Output

```
6
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
```

# R

```
library(gtools)
```

```
Error in library(gtools): there is no package called 'gtools'
```

```
library(magrittr)
f <- "perm.txt"
n <- as.numeric(readLines(f))
p <- permutations(n, n, v = 1:n)
```

```
Error in permutations(n, n, v = 1:n): could not find function "permutations"
```

```
apply(p, 1, paste, collapse = " ") %>%
cat(nrow(p), ., sep = "\n")
```

```
Error in apply(p, 1, paste, collapse = " "): object 'p' not found
```