Ejemplo n.º 1
0
 def test_simple_power(self):
     first = 5
     second = 4
     mod = 9
     result = Modular.pow_modulo(first, second, mod)
     expected = 4
     self.assertEqual(expected, result)
Ejemplo n.º 2
0
 def test_power_large_numbers(self):
     first = 2018
     second = 2018
     mod = pow(2, 32) - 1
     result = Modular.pow_modulo(first, second, mod)
     expected = 2110863454
     self.assertEqual(expected, result)
Ejemplo n.º 3
0
    def test_pow_modulo(self):
        expected = 2110863454

        a = 2018
        n = 2018
        mod = pow(2, 32) - 1

        result = Modular.pow_modulo(a, n, mod)
        self.assertEquals(expected, result)
Ejemplo n.º 4
0
def zad_2():
    base = 2018
    power = 2018
    mod = pow(2, 32) - 1

    a = Modular.pow_modulo(base, power, mod)

    t1 = int(pow(2, 16) - 1)
    result1 = a % t1
    print(" a mod( 2^16 -1)")
    print(result1)

    result2 = Modular.tau(a)
    print(" tau(a)")
    print(result2)

    result3 = Modular.jota(a)
    print(" jota(a)")
    print(result3)

    result4 = Modular.nwd([a, t1])
    print(" nwd(a, 2^16 -1)")
    print(result4)

    result5 = Modular.nww([a, t1])
    print(" nww(a, 2^16 -1)")
    print(result5)

    result61, result62 = Modular.pi_from_probability(a)
    print(" pi(a)")
    print(result61)
    print(result62)

    result7 = Modular.phi_by_kanon(a)
    print(" euler(a)")
    print(result7)

    result8 = Modular.is_prime(a)
    t2 = Modular.kanon(a)
    print(" zad2.1")
    print(result8)
    print(min(t2))

    result9 = Modular.nfermat(a)
    print(" zad2.2")
    print(result9)
    print(t2)