コード例 #1
0
def RED_Q_Q(Q):
    # Гурьянов Савелий
    # Сокращение дроби
    if integer.POZ_Z_D(Q[0]):
        nod = nat.GCF_NN_N(integer.ABS_Z_N(Q[0]), integer.ABS_Z_N(
            Q[1]))  # Делим числитель и знаменатель на их НОД
        Q[0] = integer.DIV_ZZ_Z(Q[0], nod)
        Q[1] = integer.DIV_ZZ_Z(Q[1], nod)
        return Q
    else:
        return Q
コード例 #2
0
ファイル: mainwin.py プロジェクト: mshutenkov/dmath
 def on_btn_n_gcf_released(self):
     try:
         n1 = self.get_n_n(1)
         n2 = self.get_n_n(2)
         result = natural.GCF_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)
コード例 #3
0
def open_window_nat_gcd():
    layout = [
        [sg.Text('Enter two naturals')],
        [sg.Input(key='dig1')],
        [sg.Button('GCD', key='start')],
        [sg.Input(key='dig2')],
        [sg.Text(size=(400, 10), key='out')]
    ]
    window = sg.Window('Greatest Common Divisor of natural numbers', layout, size=(460, 260), resizable=True)
    while True:
        event, values = window.read(nat.GCF_NN_N(values['dig1'], values['dig2']))
        if event == "start":
            window['out'].update()
        if event == sg.WINDOW_CLOSED:
            break
コード例 #4
0
 def test_normal(self):
     number1 = [2, [2, 7]]
     number2 = [2, [0, 6]]
     expect = [2, [2, 1]]
     result = natural.GCF_NN_N(number1, number2)
     self.assertEqual(result, expect)
コード例 #5
0
 def test_simple(self):
     number1 = [2, [1, 3]]
     number2 = [2, [5, 1]]
     expect = [1, [1]]
     result = natural.GCF_NN_N(number1, number2)
     self.assertEqual(result, expect)
コード例 #6
0
 def test_equal(self):
     number = [2, [3, 2]]
     expect = number
     result = natural.GCF_NN_N(number, number)
     self.assertEqual(result, expect)
コード例 #7
0
 def test_zero(self):
     number = [2, [3, 2]]
     zero = [1, [0]]
     expect = number
     result = natural.GCF_NN_N(number, zero)
     self.assertEqual(result, expect)
コード例 #8
0
 def test_zeros(self):
     zero = [1, [0]]
     expect = zero
     result = natural.GCF_NN_N(zero, zero)
     self.assertEqual(result, expect)