vendredi 14 août 2015

generate n length unique random numbers using javascript

Following are the rules:

generate random numbers of length N. Not more than two consecutive numbers should be same.

i written code , but even though 2 same consecutive numbers allowed, it will not take it. all unique random numbers will be generated.

i keep one temp variable, which stores prev number generated, if it matches the present generate number, then discard and generate again.

Please help me out using javascript.




Aucun commentaire:

Enregistrer un commentaire