The questions looks to me like an XY problem.
It is not clear why the gift card numbers need to consist of 16 digits. Amazon has 1.5 million employees, McDonald's has 1.9 million. Even for such huge companies 7 digits would be sufficient. Even if you add a checksum digit, 16 digits would not be necessary.
For the given purpose, generation of gift card numbers, a random generator is not necessary. We usually use random generator: A) When we cannot keep the whole registry of possible numbers, e.g. when it would require much CPU load, or much storage, or long response time; B) If we want that many parties can generate numbers independently and keep the probability of collisions low. In your case you have a full control of all numbers to be generated. The numbers can be generated at once, by a single application.
That's why I'd suggest following approach:
- Generate a list of numbers of git cards starting from 1 to the number of employees.
- Shuffle this list.
Then every employee number will be associated with some randomly looking gift card number.
If you want to keep gift card numbers over years unchanged and not generate them every year, and if you expect that your company is growing and new employees will need gift cards, and you want to avoid correlation of higher numbers with new employees, then yes, random generator would be helpful.
In such case you can take the number of employees, multiply it by 10 or by 100, and generate numbers in this range. For instance, if there are 10 000 employees in your company, you can take a range 1 to 1 000 000 and generate numbers randomly and assign them to employees. Checking of collisions will be easy, because keeping an array of let say 1 000 000 elements in memory is simple and fast. In case of collision you just generate a new number, until there is no collision, or add some fixed value like 1, until there is no collision.
When later on new cards will be needed, there will be sufficient "wholes" in this range for new numbers.
A function can look as follows:
next_card_number = Math.floor( Math.random() * N )
N - the highest gift card number. For instance, if there are 10 000 employees, you can use 999 999 as the highest gift card number.