示例#1
0
def phi1(x):
    #phi function implenment 1
    if isprime(x):
        return x-1
    count = 0
    for i in xrange(x):
        if gcd(i,x) == 1:
            count += 1
    return count
示例#2
0
def findorderfractions2(x,a,b,c,d):
    lb = x*a/b+1
    ub = x*c/d

    if isprime(x):
        return ub-lb+1

    res = [1 for i in xrange(lb,ub+1) if gcd(i,x) == 1]

    return len(res)
示例#3
0
def nextCN(n):
    p0 = nextC(n,0,1)
    a0 = p0[0]
    n0,d0 = a0,1
    yield n0,d0
    p1 = nextC(*p0[1:])
    a1 = p1[0]
    n1,d1 = a1*a0+1,a1
    g = gcd(n1,d1)
    n1,d1 = n1/g,d1/g
    yield n1,d1
    while True:
        p2 = nextC(*p1[1:])
        p1,p0 = p2,p1
        n2 = p2[0]*n1+n0
        d2 = p2[0]*d1+d0
        g = gcd(n2,d2)
        n2,d2 = n2/g,d2/g
        d1,d0 = d2,d1
        n1,n0 = n2,n1
        yield n2,d2
示例#4
0
文件: euler276.py 项目: Kylar42/wvup
import eulerutils as eu

count = 0
for i in (1,9999998):
	if(i % 1000 == 0):
		print "Count i: %i" % (i)
	for j in (i, 9999999):
		k = 10000000 - (i + j)
		if 1 == eu.gcd(i, j) and 1 == eu.gcd(j, k) and 1 == eu.gcd(i,k):
			print "Found primitive: %i, %i, %i" % (i,j,k)
			count += 1


print "Count: %i" % count
示例#5
0
import eulerutils as eu

count = 0
for i in (1, 9999998):
    if (i % 1000 == 0):
        print "Count i: %i" % (i)
    for j in (i, 9999999):
        k = 10000000 - (i + j)
        if 1 == eu.gcd(i, j) and 1 == eu.gcd(j, k) and 1 == eu.gcd(i, k):
            print "Found primitive: %i, %i, %i" % (i, j, k)
            count += 1

print "Count: %i" % count