Largest number smaller than or equal to N divisible by K | C ++ implementation of the above approach ; Function to find the largest number smaller than or equal to N that is divisible by k ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int findNum ( int N , int K ) { int rem = N % K ; if ( rem == 0 ) return N ; else return N - rem ; } int main ( ) { int N = 45 , K = 6 ; cout << " Largest ▁ number ▁ smaller ▁ than ▁ or ▁ equal ▁ to ▁ " << N << " that is divisible by " < < ▁ K ▁ < < ▁ " is " return 0 ; }