Multiple of x closest to n | Function to calculate the smallest multiple ; Driver program
function closestMultiple ( n , x ) { if ( x > n ) return x ; n = n + parseInt ( x / 2 , 10 ) ; n = n - ( n % x ) ; return n ; } let n = 56287 , x = 27 ; document . write ( closestMultiple ( n , x ) ) ;