示例#1
0
def __is_it_possible_for_p(r: pwnlib.tubes.remote.remote, rnd: int,
                           v: bytes) -> None:
    """Format should be something like: `Supa ez.  Is it possible for p to equal Mjg5Cg==? [y/n]`"""
    p = int(b64decode(v))
    print(f'[*] Got value p={p} ... ')
    k = primes.check(p)
    print(f'[*] Is it possible? {k} ... ')
    yn(r, k)
示例#2
0
def next_prime(n):
    if n <= 1:
        return 2
    else:
        n += 1
        while not primes.check(n):
            n += 1
        return n
示例#3
0
def get_total_primes(a, b):
    # a < b < 10^7
    primes = ['2', '3', '5', '7']
    test_list = []
    k = 0
    m = 0
    result = 0
    total_prime = False
    for i in range(a, b):
        string = str(i)

        # test j (every digit of i) against primes list
        for j in string:
            if j in primes:
                test_list.append(j)
            if len(test_list) == len(string):
                total_prime = True

        # test whether i is prime number using primePy
        if primes.check(i) == True:
            m += 1

        # final check of whether we have a "total prime"
        if total_prime == True and m == 1:
            result += 1

        # change total_prime boolean to false
        total_prime = False

        # reset m to 0
        m = 0

        # make test_list empty again
        test_list = []

    return result
示例#4
0
from primePy import primes

# upto 메서드 예제
primes_to_10 = primes.upto(10)
print("10까지의 소수 리스트:", primes_to_10)
primes_to_100 = primes.between(100, 1000)
print("100까지의 소수 리스트:", len(primes_to_100))
print()  # 띄어쓰기를 위해서

# 10까지의 소수 리스트: [2, 3, 5, 7]
# 100까지의 소수 리스트: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

# first 메서드 예제
first_5_primes = primes.first(5)
print("처음 5개 소수 리스트:", first_5_primes)
first_10_primes = primes.first(10)
print("처음 10개 소수 리스트:", first_10_primes)
print()

# 처음 5개 소수 리스트: [2, 3, 5, 7, 11]
# 처음 10개 소수 리스트: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]


# check 메서드 예제
print("15는 소수인가요?", primes.check(15))
print("277은 소수인가요?", primes.check(277))
print()

# 15는 소수인가요? False
# 277은 소수인가요? True
示例#5
0
def is_attractive(n):
    factors = primes.factors(n)
    num_factors = len(factors)
    return num_factors != 1 and primes.check(num_factors)
示例#6
0
# called the Euclid Numbers (see wiki). Write a script that finds the smallest
# Euclid Number that is not prime. This challenge was proposed by
# Laurent Rosenfeld.

import sys
from primePy import primes

def next_prime(n):
    if n <= 1:
        return 2
    else:
        n += 1
        while not primes.check(n):
            n += 1
        return n

def euclid_iter():
    prime = 1
    prime_prod = 1
    while True:
        prime = next_prime(prime)
        prime_prod *= prime
        yield prime_prod+1

for n in euclid_iter():
    if primes.check(n):
        pass
    else:
        print(n)
        break
# 1978 소수 찾기

from primePy import primes

sum = 0
length = int(input())
inp = input().split(" ")
for t in inp:
    t = int(t)
    if primes.check(t) == True:
        sum +=1
        if t == 1:
            sum -= 1

    else:
            continue
print(sum)






# def prime_number(number): #개수
#     for num in range(number):
#         inp = map(int,input().split(" "))
#         lis = []
#         for x in range(1,inp):
#             for y in range(1,inp):
#                 prime = x*y
#                 if prime == number: