Check if number can be displayed using seven segment led | Pre - computed values of segment used by digit 0 to 9. ; Check if it is possible to display the number ; Finding sum of the segments used by each digit of the number ; Driver Code ; Function call to print required answer
const seg = [ 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] ; function LedRequired ( s , led ) { var count = 0 ; for ( var i = 0 ; i < s . length ; ++ i ) { count += seg [ ( s [ i ] ) - 48 ] ; } if ( count <= led ) return " " ; else return " " ; } var S = " " ; var led = 20 ; document . write ( LedRequired ( S , led ) + " " ) ;