Calculate the numbers taken to reach the distinct numbers.
Given 'n' distinct random numbers, how many random numbers are needed to generate distinct number? Unable to get the total elements took to find distinct numbers. For say, I need 100 distinct random numbers, it may take more than 100 numbers to get distinct random numbers. All I am getting is only count of distinct values (duplicates) and not the total numbers count to reach the count of distinct values. Below is my code: import random def numbers(n): l=list() # Empty list Distinct_nums = 0 # Initializing Distinct numbers #while Distinct_nums == n: for i in range(n*n): r = random.randint(1,1000) # Generating random numbers if r not in l: # Filtering distinct numbers l.append(r) Distinct_nums += 1 return Distinct_nums # printing distinct numbers n = int(input("Enter the number of elements: ")) print(numbers(n))