Exemplo n.º 1
0
def zad_3():
    n = 5
    solutions = []
    primes = Modular.nPrime(n)
    ran = range(1, 2048)
    for i in range(1, n + 1):
        solutions.append(Modular.ModuloEquatation(1, i, primes[i - 1], ran))

    base = set(solutions[0])
    for i in range(1, n):
        B = set(solutions[i])
        base = base.intersection(B)

    x = min(base)

    print(x)
    is_prime = Modular.is_prime(x)
    print("is prime:", is_prime)

    result1 = Modular.tau(x)
    print(result1)

    result2 = Modular.phi(x)
    print(result2)

    result3 = Modular.jota(x)
    print(result3)

    result4 = Modular.kanon(x)
    print(result4)
Exemplo n.º 2
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))
Exemplo n.º 3
0
 def test_phi_prime(self):
     arg = 199
     result = Modular.phi(arg)
     expected = 198
     self.assertEqual(expected, result)
Exemplo n.º 4
0
 def test_simple_phi(self):
     arg = 20
     result = Modular.phi(arg)
     expected = 8
     self.assertEqual(expected, result)
Exemplo n.º 5
0
 def test_euler4(self):
     expected = 1
     a = 1
     self.assertEquals(expected, Modular.phi(a))
     self.assertEquals(expected, Modular.phi_by_kanon(a))
     self.assertEquals(expected, Modular.phi_by_kanon2(a))
Exemplo n.º 6
0
 def test_euler3(self):
     expected = math.pow(2, 16)
     a = int(math.pow(2, 16) + 1)
     self.assertEquals(expected, Modular.phi(a))
     self.assertEquals(expected, Modular.phi_by_kanon(a))
     self.assertEquals(expected, Modular.phi_by_kanon2(a))