pupy.amazon_prime

Module Contents

range
prime_gen(plim=0, kprimes=None)

Infinite (within reason) prime number generator

My big modification is the pdiv_dictionary() function that recreats the dictionary of divisors so that you can continue to generate prime numbers from a (sorted) list of prime numbers.

Based on:
eratosthenes by David Eppstein, UC Irvine, 28 Feb 2002 http://code.activestate.com/recipes/117119/ and the thread at the url
Parameters:
  • plim (int) – prime_limit; default=0 makes for an infinite generator
  • kprimes (iter) – known_primes as an iterable (Default value = None)
prime_factorization_gen(n)

generates all numbers in the prime factorization of n

Parameters:n (int) – number to be factored
prime_factors_gen(n)

prime factors generator

Parameters:n (int) – number to be factorized
is_prime(number)

Checks if a number is prime

Parameters:number (int) – number to check if is prime
Returns:-> True if number is prime
Return type:bool
class OctopusPrime(plim=100)

Bases:collections.MutableSequence

OctopusPrime, the 8-leg autobot, here to help you find PRIMES

_transform(self, n=None)

TRANSFORM / grow the list

Parameters:n – (Default value = None)
primes_below(self, upper_bound)

Lists primes, p, such that p < upper_bound

Parameters:upper_bound (int) – exclusive upper bound
Returns:-> primes less than upper_bound
Return type:list
primes_between(self, lower_bound, upper_bound)

Lists primes, p, such that, lower_bound < p < upper_bound

Parameters:
  • lower_bound (int) – exclusive lower bound
  • upper_bound (int) – exclusive upper bound
Returns:

-> primes between lower_bound and upper_bound

Return type:

list

__len__(self)
__getitem__(self, i)
__delitem__(self, i)
__setitem__(self, key, value)
insert(self, index, object)
Parameters:
  • index
  • object
__str__(self)
__repr__(self)