def INT_Q_B(A): # Аносов Павел # Проверка на целое if nat.MOD_NN_N(integer.ABS_Z_N(A[0]), A[1]) == [ 0 ]: # Проверка остатка от деления первого числа на второе return True # Если ноль - число целое else: return False
def on_btn_n_modn_released(self): try: n1 = self.get_n_n(1) n2 = self.get_n_n(2) result = natural.MOD_NN_N(n1, n2) self.add_history_record('%d %% %d = %d' % ( common.N_to_num(n1), common.N_to_num(n2), common.N_to_num(result), )) except Exception as e: self.on_exception(e)
def open_window_nat_mod(): layout = [ [sg.Text('Enter two naturals')], [sg.Input(key='dig1')], [sg.Button('Mod', key='start')], [sg.Input(key='dig2')], [sg.Text(size=(400, 10), key='out')] ] window = sg.Window('The remainder of the division of natural numbers', layout, size=(460, 260), resizable=True) while True: event, values = window.read() if event == "start": window['out'].update(nat.MOD_NN_N(values['dig1'], values['dig2'])) if event == sg.WINDOW_CLOSED: break
def test_normal(self): number1 = [5, [6, 5, 3, 6, 4]] number2 = [2, [8, 4]] expect = [2, [6, 3]] result = natural.MOD_NN_N(number1, number2) self.assertEqual(result, expect)
def test_small(self): number1 = [2, [1, 2]] number2 = [2, [2, 2]] expect = [2, [1, 2]] result = natural.MOD_NN_N(number1, number2) self.assertEqual(result, expect)
def test_equal(self): number = [3, [6, 2, 6]] expect = [1, [0]] result = natural.MOD_NN_N(number, number) self.assertEqual(result, expect)
def test_zero(self): zero = [1, [0]] number = [3, [6, 2, 6]] expect = [1, [0]] result = natural.MOD_NN_N(zero, number) self.assertEqual(result, expect)