lundi 18 janvier 2021

Write function that returns random integer greater than S, ending with 0

I'm supposed to write a function that returns a random integer greater than S and ending with 0. S is between 1 and 999,999,999. For example, S = 13 and your function may return 50.

I found a solution that is supposed to work in Java, but I can't make it work in JavaScript.

int max = 100000000;                 
int min = 0;
int diff = max - min;
Random arbitrary = new Random();
int i = arbitrary.nextInt(diff + 1);
i += min;
System.out.print("The Number is " + i * 10);



Aucun commentaire:

Enregistrer un commentaire