Program for quotient and remainder of big number | Function to calculate the modulus ; Store the modulus of big number ; Do step by step division ; Update modulo by concatenating current digit . ; Update quotient ; Update mod for next iteration . ; Flag used to remove starting zeros ; Driver Code
def modBigNumber ( num , m ) : NEW_LINE INDENT vec = [ ] NEW_LINE mod = 0 NEW_LINE for i in range ( 0 , len ( num ) , 1 ) : NEW_LINE INDENT digit = ord ( num [ i ] ) - ord ( '0' ) NEW_LINE mod = mod * 10 + digit NEW_LINE quo = int ( mod / m ) NEW_LINE vec . append ( quo ) NEW_LINE mod = mod % m NEW_LINE DEDENT print ( " Remainder ▁ : " , mod ) NEW_LINE print ( " Quotient ▁ : " , end = " ▁ " ) NEW_LINE zeroflag = 0 ; NEW_LINE for i in range ( 0 , len ( vec ) , 1 ) : NEW_LINE INDENT if ( vec [ i ] == 0 and zeroflag == 0 ) : NEW_LINE INDENT continue NEW_LINE DEDENT zeroflag = 1 NEW_LINE print ( vec [ i ] , end = " " ) NEW_LINE DEDENT return NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT num = "14598499948265358486" NEW_LINE m = 487 NEW_LINE modBigNumber ( num , m ) NEW_LINE DEDENT