js 取接近x 倍数的整数
function closestMultiple(n, x)
{
if (x > n)
return x;
n = n + parseInt(x / 2, 10);
n = n - (n % x);
return n;
}
测试
closestMultiple(6,5)
5
closestMultiple(19,5)
20
closestMultiple(19,100)
100
closestMultiple(199,100)
200