Number of days after which tank will become empty | C # code to find number of days after which tank will become empty ; Method returns minimum number of days after which tank will become empty ; Driver code
using System ; class GFG { static int minDaysToEmpty ( int C , int l ) { if ( l >= C ) return C ; double eq_root = ( Math . Sqrt ( 1 + 8 * ( C - l ) ) - 1 ) / 2 ; return ( int ) ( Math . Ceiling ( eq_root ) + l ) ; } static public void Main ( ) { Console . WriteLine ( minDaysToEmpty ( 5 , 2 ) ) ; Console . WriteLine ( minDaysToEmpty ( 6514683 , 4965 ) ) ; } }