Answer the question
In order to leave comments, you need to log in
How to add rand odds?
For example: rand(1,2);
How to make it so that the probability of dropping 1 was 40%, and 2 60%
Answer the question
In order to leave comments, you need to log in
If specifically for this example, then you can simply do this:
if (rand(1,100) <= 40) {
echo 1;
} else {
echo 2;
}
You get Nan because 2 + undefined
this NaN
function sumTo(n) {
if(n > 1) {
return (n + sumTo(n-1));
}
return 1;
}
Because sumTo(1) without else will return undefined
And undefined + 14 = NaN
Thanks to !
Am I understanding the chain correctly?
5 + 10 = 15
4 + 6 = 10
3 + 3 = 6
2 + 1 = 3
return 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question