How to compute mod of a big number ? | Function to compute num ( mod a ) ; Initialize result ; One by one process all digits of ' num ' ; Driver Code
function mod ( num , a ) { let res = 0 ; for ( let i = 0 ; i < num . length ; i ++ ) res = ( res * 10 + num [ i ] - ' ' ) % a ; return res ; } let num = " " ; document . write ( mod ( num , 10 ) ) ;