mardi 22 novembre 2016

Solve the random number logic

I have a function myrand() it will generate random number from 1 to 5. I want to make another function by using myrand() that will generate random number form 1 to 7. I write something like that.

function newrand()
{
    return myrand()+2;
}

Above logic is not that i want it will never return me 1 or 2. I don't want to use any if condition so what should i do to make logic for random number.




Aucun commentaire:

Enregistrer un commentaire