I have to create a method that generates randomly 2 numbers, that divided give as result a number without decimals. For example:
int result = 4 / 2; //is ok
int result = 4 / 3; //is NOT ok
I already create a recursive method that, when the result is a decimal number, call itself and generates 2 new numbers. But, of course, this is not the best approach since, in theory, I may get as a result a decimal number forever!
Is there a good way to achieve my goal?
Thank in advance.
Aucun commentaire:
Enregistrer un commentaire