Multiple of x closest to n | C # program to calculate smallest multiple of x closest to a given number ; Function to calculate the smallest multiple ; Driver program
using System ; 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 ( ) { int n = 56287 , x = 27 ; Console . WriteLine ( closestMultiple ( n , x ) ) ; } }