In addition to the correct point that @Tim and @HaitaoDu make, there may be additional reasons to distrust a supposed random number generator that "always return[s] 4".
Suppose I know that the numbers are produced by a deterministic algorithm running in a computer (not, say, incorporating inputs from a quantum mechanical device), even if I don't know that the algorithm is actually return 4
. Every deterministic pseudorandom number generating algorithm has a finite period--i.e. after outputting a certain quantity of "random" numbers, the sequence of returned numbers must repeat. So if I keep drawing more and more numbers from your "random number" program, at some point the quantity of numbers that have been produced will be close to the largest period that any known random number generating algorithm would produce. The fact that I have only seen the number 4 through all of those draws, and am now close to exceeding any reasonably possible period--or even close to half of such a period--would be evidence that what is producing the numbers is not a legitimate attempt at a pseudorandom number generating algorithm. Granted, it may take a lot of time and computing power to get to this point. (The largest pseudorandom number algorithm period that I have heard of is that of a standard Mersenne Twister, $2^{ 219937−1}$.)
Furthermore, any non-horrible random number generating algorithm is supposed to try to approximate a uniform distribution with independent draws--of 1 through 10, in this case. There have been many algorithms proposed that are not good, and even very bad, because they failed to come sufficiently close to this goal. I am thinking of algorithms that are not truly horrible. return 4
is beyond truly horrible, and that will be apparent after many draws: if a non-horrible pseudorandom number generator has produced enough numbers that a moderately significant percentage of its period has been used up, those numbers can't all be the same, because even a bad, but not truly horrible algorithm would superficially seem to return numbers that are independent and uniformly distributed. A very long sequence of 4's that take up a significant percentage of the possible period of a psedurorandom number generating algorithm does not have that appearance, even superficially, so the algorithm that produces that long sequence of 4's must be truly horrible--at the very least.