示例#1
0
def zad_5():
    ran = range(0, 1024)
    result0 = Modular.ModuloEquatation(8, 8, 1024, ran)

    print("NWD")
    print(Modular.nwd(result0))

    print('Sum of x')
    print(np.sum(result0))

    max_value = 0
    max_power = 0
    for i in range(len(result0)):
        value = result0[i]
        power = Modular.phi(value)
        if max_power < power:
            max_power = power
            max_value = value
        elif power < max_power:
            a = pow(max_value, max_power)
            b = pow(value, power)
            if a < b:
                max_power = power
                max_value = value

    print("max")
    print(pow(max_value, max_power))

    print('k')
    print(len(result0))
示例#2
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)
示例#3
0
def zad_4():
    a = pow(2, 16) - 1
    b = pow(2, 16) + 1

    result1 = Modular.nwd([a, b])
    print("nwd", result1)

    result2 = pow(a, 32) * pow(b, 32)  # nwd is 1
    print("nww", result2)

    print("phi", Modular.phi_by_kanon_pow(a, b))

    nwd, x, y = Modular.euklidesEquatation(a, b)
    kanonx = Modular.kanon(x)
    kanony = Modular.kanon(y)

    print("x:", x)
    print("kanon x:", kanonx)

    print("y:", y)
    print("kanon y:", kanony)
示例#4
0
 def test_NWD2(self):
     expected = 1
     a = int(math.pow(2, 16) + 1)
     b = int(math.pow(2, 16) - 1)
     self.assertEquals(expected, Modular.nwd([a, b]))
示例#5
0
 def test_NWD1(self):
     expected = 1
     a = 5
     b = 12
     self.assertEquals(expected, Modular.nwd([a, b]))
示例#6
0
 def test_simple_nwd_one_number(self):
     arg = [48]
     result = Modular.nwd(arg)
     expected = 48
     self.assertEqual(expected, result)
示例#7
0
 def test_simple_nwd_coprime(self):
     arg = [48, 25]
     result = Modular.nwd(arg)
     expected = 1
     self.assertEqual(expected, result)
示例#8
0
 def test_simple_nwd(self):
     arg = [12, 3, 48]
     result = Modular.nwd(arg)
     expected = 3
     self.assertEqual(expected, result)
示例#9
0
 def test_NWD3(self):
     expected = 6
     a = 24
     b = 18
     self.assertEquals(expected, Modular.nwd([a, b]))