Check if a large number is divisible by 11 or not | Function to find that number divisible by 11 or not ; Compute sum of even and odd digit sums ; When i is even , position of digit is odd ; Check its difference is divisible by 11 or not ; Driver Code
function check ( str ) { let n = str . length ; let oddDigSum = 0 , evenDigSum = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) oddDigSum += ( str [ i ] - ' ' ) ; else evenDigSum += ( str [ i ] - ' ' ) ; } return ( ( oddDigSum - evenDigSum ) % 11 == 0 ) ; } let str = " " ; if ( check ( str ) ) document . write ( " " ) ; else document . write ( " " ) ;