我想查找更接近特定數字的數字。在當前的例子partitucal號碼是15.我會通過N到方法,它將返回我的最近15 完全分開我想這樣找到更接近的值
function getCloser(no){
if(no is closer to 0) // in this case no can be 1,2,3,4,5,6,7
return 0
if(no is closer to 15) // in this case no can be 8,9,10,11,12,13,15,16...22
return 15
if(no is closer to 30) // in this case no can be 23 to 37
return 30
and so on...
}
尼斯和乾淨! +1 – Nobita 2011-12-28 08:08:46