Exemplo n.º 1
0
def is_sum_pt(num):
  """
  check whether num can written as
  the sum of a prime and twice a square
  """
  for p in primes_i():
    if num <= p:
      break
    if is_twice_of_square(num - p):
      return True  # satisfy property.
  return False
Exemplo n.º 2
0
def is_sum_pt(num):
    """
  check whether num can written as
  the sum of a prime and twice a square
  """
    for p in primes_i():
        if num <= p:
            break
        if is_twice_of_square(num - p):
            return True  # satisfy property.
    return False
Exemplo n.º 3
0
def num_of_prime_factors(num):
  """return number of prime factor. this is distinct prime factors"""
  n = num
  pfs = 0  # num of prime factor
  for p in primes_i():
    if n % p == 0:
      # p is prime factor of n
      pfs += 1
      while n % p == 0:
        n = n / p
    if n == 1:
      break;
  return pfs
Exemplo n.º 4
0
def num_of_prime_factors(num):
    """return number of prime factor. this is distinct prime factors"""
    n = num
    pfs = 0  # num of prime factor
    for p in primes_i():
        if n % p == 0:
            # p is prime factor of n
            pfs += 1
            while n % p == 0:
                n = n / p
        if n == 1:
            break
    return pfs