text: Minimum value to be added to X such that it is at least Y percent of N | Function to return the required value that must be added to x so that it is at least y percent of n ; Required value ; If x is already >= y percent of n ; Driver code
code: function minValue ( n , x , y ) { let val = ( y * n ) / 100 ; if ( x >= val ) return 0 ; else return ( Math . ceil ( val ) - x ) ; } let n = 10 , x = 2 , y = 40 ; document . write ( minValue ( n , x , y ) ) ;