> 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/p/permutations_with_repetitions.md).

# Permutations with repetitions

```ruby
var k = %w(a b c)
var n = 2

cartesian([k] * n, {|*a| say a.join(' ') })
```

## Output:

```
a a
a b
a c
b a
b b
b c
c a
c b
c c
```
