Using a functionrand7() that returns an integer from 1 to 7 (inclusive) with uniform probability, implement a function rand5() that returns an integer from 1 to 5 (inclusive).
This is a really simple question, and I didn’t feel satisfied so I also implemented a solution that returns a random (inclusive) integer but guarantees that the integer remains unique until the entire range is exhausted – that is, rand(10) below would never return a duplicate number until all numbers from 1 through 10 have also been previously returned.