需要帮助的人,我怎样才能获得2和3的分歧 [英] Need Help Guys, How Can I Get The Divisble Of 2 And 3
问题描述
可以被2整除,它应该是-2而不是数字
可以被2和3整除,它应该是-1而不是数字
阵列的部分预期内容如下所示:
[1,-2,-3,-2,5,-1, 7,-2,-3,-2,11,...,995,-1,997,-2,-3,-2]
< script>
var arr = [];
函数getRamdom(num){
返回Math。 round(Math.random()* num)+1;
}
for(var i = 0l i< = 1000; i ++){
if(
}
< / script>
divisible by 2, it should be -2 instead of the number
divisible by 2 and 3, it should be -1 instead of the number
Part of the expected content of the array is shown below:
[ 1, -2, -3, -2, 5, -1, 7, -2, -3, -2, 11, ..., 995, -1 ,997, -2, -3, -2 ]
<script>
var arr=[];
function getRamdom (num){
return Math.round(Math.random() *num)+1;
}
for(var i=0l i<=1000;i++){
if(
}
</script>
推荐答案
要测试2和3可分割,这意味着可以用6整除,所以你应该使用下一个条件:
To test divisible with 2 AND 3, this means divisible with 6, so you should use the next condition:
if(number % 6 == 0)
{
//The number is divisible with 6!
}
这篇关于需要帮助的人,我怎样才能获得2和3的分歧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!