示例#1
0
def main():
	MAXP = 100000
	primes = SIEVE.sieve(MAXP, MAXP)
	for line in sys.stdin:
		n = int(line.rstrip())
		assert n <= MAXP*MAXP
		#print(divisors(n, primes), sum_divisors(n, primes), prime_parity(n, primes), euler_phi(n, primes), moebius(n, primes))
		print(divisors(n, primes))
		sys.stdout.flush()
示例#2
0
文件: FACTOR.py 项目: vbonifaci/algo
def main():
    MAXP = 100000
    prime = SIEVE.sieve(MAXP, MAXP)
    for line in sys.stdin:
        n = int(line.strip())
        assert n <= MAXP * MAXP
        if n == 1:
            print("1 = 1")  # special case
        else:
            p, k, m = factor(n, prime)
            if k != 1:
                s = "{} = {}^{}".format(n, p, k)
            else:
                s = "{} = {}".format(n, p)
            while m != 1:
                p, k, m = factor(m, prime)
                if k != 1:
                    s += " * {}^{}".format(p, k)
                else:
                    s += " * {}".format(p)
            print(s)