> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/e/euclid-mullin_sequence.md).

# Euclid-Mullin sequence

```ruby
func f(n) is cached {
    return 2 if (n == 1)
    lpf(1 + prod(1..^n, {|k| f(k) }))
}
 
say f.map(1..16)
say f.map(17..27)
```

#### Output:

```
[2, 3, 7, 43, 13, 53, 5, 6221671, 38709183810571, 139, 2801, 11, 17, 5471, 52662739, 23003]
[30693651606209, 37, 1741, 1313797957, 887, 71, 7127, 109, 23, 97, 159227]
```
