Multiple of x closest to n | Java program to calculate the smallest multiple of x closest to a given number ; Function to calculate the smallest multiple ; driver program
import java . io . * ; class Solution { static int closestMultiple ( int n , int x ) { if ( x > n ) return x ; n = n + x / 2 ; n = n - ( n % x ) ; return n ; } public static void main ( String [ ] args ) { int n = 56287 , x = 27 ; System . out . println ( closestMultiple ( n , x ) ) ; } }