Find largest factor of N such that N / F is less than K | Function to find the value of X ; Loop to check all the numbers divisible by N that yield minimum N / i value ; Print the value of packages ; Given N and K ; Function Call
function findMaxValue ( N , K ) { let packages ; let maxi = 1 ; for ( let i = 1 ; i <= K ; i ++ ) { if ( N % i == 0 ) maxi = Math . max ( maxi , i ) ; } packages = parseInt ( N / maxi ) ; document . write ( packages ) ; } let N = 8 , K = 7 ; findMaxValue ( N , K ) ;