특정 숫자에 더 가까운 숫자를 찾고 싶습니다. 현재 예에서 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