I had nothing to do so I just created this little thing, copy & paste the code in your console application and then run it.
So what you do is specify an integer, then specify the minimum and maximum range and it will generate a random integer between that range until your specific integer is generated and tell you how many times it tried to reach that integer.
Tell me if I need to improve something.
Code
Module ConsoleModule
Sub Main()
Console.Write("Integer to reach: ")
Dim iToReach As Integer = CInt(Console.ReadLine)
Console.Write("Min range: ")
Dim minRange As Integer = CInt(Console.ReadLine)
Console.Write("Max range: ")
Dim maxRange As Integer = CInt(Console.ReadLine)
startReach(iToReach, minRange, maxRange)
End Sub
Sub startReach(ByVal iTR As Integer, ByVal minR As Integer, ByVal maxR As Integer)
Dim amountOfTries As Integer = 0
Dim iReached As Integer
Do Until iReached = iTR
Dim iRnd As New Random
iReached = iRnd.Next(minR, maxR)
amountOfTries += 1
Console.WriteLine(amountOfTries)
If iReached = iTR Then
Console.WriteLine("Integer has been reached!")
Console.WriteLine("Amount of tries: " & amountOfTries)
End If
Loop
Main()
End Sub
End ModuleSo what you do is specify an integer, then specify the minimum and maximum range and it will generate a random integer between that range until your specific integer is generated and tell you how many times it tried to reach that integer.
Tell me if I need to improve something.


