jeudi 16 avril 2020

I'm trying to generate a random distinct 3 or 4 digit number

I'm trying to generate a random distinct 3 or 4 digit number in Java, without using loops, arrays, or methods, just the basic stuff like if functions.

I tried

(int)(Math.random()*9899+100);

But it's only returning 4 digit indistinct numbers.




Aucun commentaire:

Enregistrer un commentaire