# How do I create an array with random unique numbers in a specific range?

**URL:** <https://discourse.julialang.org/t/how-do-i-create-an-array-with-random-unique-numbers-in-a-specific-range/115901>\
**Category:** New to Julia\
**Tags:** question, random\
**Created:** [June 20, 2024, 4:14am UTC](https://discourse.julialang.org/t/how-do-i-create-an-array-with-random-unique-numbers-in-a-specific-range/115901 "2024-06-20T04:14:31Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [June 21, 2024, 10:31pm UTC](https://discourse.julialang.org/t/how-do-i-create-an-array-with-random-unique-numbers-in-a-specific-range/115901/8 "2024-06-21T22:31:27Z")

</div>

If it matters, it might be more efficient to do:

```julia
using StatsBase
sample(1:40, 30; replace=false)

```

---

_[View the full topic](https://discourse.julialang.org/t/how-do-i-create-an-array-with-random-unique-numbers-in-a-specific-range/115901)._
