示例#1
0
import prime

primesUnder20 = prime.primesUnder(20)
print primesUnder20

primeMap = {}

for curPrime in primesUnder20:
    primeMap[curPrime]=0


for x in range(1,20):
    for p in primesUnder20:
        if numTimesDivides(x,p)>primeMap[p]:
            primeMap[p]= numTimesDivides(x,p)
#        print primeMap

print primeMap
product = 1
for x in primeMap:
    product = product * math.pow(x,primeMap[x])
    print 'x is ' + str(x)
    print 'pmat at x is ' + str(primeMap[x])
    print 'pow is ' + str(math.pow(x,primeMap[x]))

print product
示例#2
0
import prime

f = open('2million.txt','w')

primesList = prime.primesUnder(2000000)
for x in primesList:
    f.write(str(x))
    f.write('\n')
print 'doneWithPrimes'
ans = sum(primesList)
print ans

f.close()
示例#3
0
import sys
sys.path.append("..")
import prime as p

pList=p.primesUnder(100)


def getPFDict(x):
	rtnVal={}
	for i in range(1,x):
		rtnVal[i]=p.getFactorDict(i,pList)
	return rtnVal

PFD=getPFDict(103)

def makePowDict():
	powDict={}
	for b in range(2,101):
		print b
		for p in range(2,101):
			insertIntoPowDict(powDict, (b,p))
	return powDict

def insertIntoPowDict(powDict, pair):
	found=False
	for k in powDict.keys():
		if pairsSame(k,pair):
			#print "found"
			#print k
			#print pair
			#print ""