Make gen_random() random

random_init() effectively calls srand() that reset the seed for the pseudo-random sequence. Because it is used within a loop, it will cause all the NN_DIGIT of a to be equal.

Hope it helps.

Regards,
Tony