Random integer in range giving untrue?

Solution:

Example

Function