我想查找更接近特定数字的数字。在当前的例子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