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