How NOT to write a random number generator

Dan'l Schmidt dschmidt at athena.mit.edu
Tue Jul 18 13:15:14 AEST 1989


int egregious_random_number_generator()
{
  static int seed = 27;

  if (seed % 2)
    return (seed = seed * 3 + 1);
  else
    return (seed = seed / 2);
}

Dan (they'll never notice)



More information about the Comp.lang.c mailing list