you're using rand(1,100000) to generate a random integer RGB value whereas the range of possible values is much larger: 0 to 2^24-1 = 16777215.
thus if you want to select from the range of all possible RGB values, you should use rand(0, 16777215)
edit: is #N a valid colour if N is expressed in base10?