If both 4 s and 7 s are there in digit sum , we subtract a 4.
else { a ++ ; sum -= 4 ; } } if ( sum < 0 ) { Console . Write ( " - 1n " ) ; return ; } for ( int i = 0 ; i < a ; i ++ ) Console . Write ( "4" ) ; for ( int i = 0 ; i < b ; i ++ ) Console . Write ( "7" ) ; Console . WriteLine ( ) ; }