def divisors(n):
    factors = RetFact(n)
    factors.append(1)
    fact=[]
    l = len(factors)
    for z in xrange(2,l+1):
      y = combinations(factors,z)
      
      for yy in y:
         yyy = list(yy)
         #print yyy
         s1 = 1
         for yyyy in yyy:
           s1*=yyyy
         fact.append(s1)
    fact.append(1)
    fact = sorted(list(set(fact)))
    #print fact
    return fact
def divisors(n):
    factors = RetFact(n)
    factors.append(1)
    fact = []
    l = len(factors)
    for z in xrange(2, l + 1):
        y = combinations(factors, z)

        for yy in y:
            yyy = list(yy)
            #print yyy
            s1 = 1
            for yyyy in yyy:
                s1 *= yyyy
            fact.append(s1)
    fact.append(1)
    fact = sorted(list(set(fact)))
    #print fact
    return fact
示例#3
0
def PhiPrimes(n):

    totfacts = []

    n1 = n - 1

    totfacts = RetFact(n1)
    allfactsfound = False

    while allfactsfound == False:
        newfactfound = False
        for m in totfacts:
            o = RetFact(m - 1)
            for p in o:

                if p < 2: continue
                if not p in totfacts:
                    totfacts.append(p)
                    newfactfound = True
        if newfactfound == False: allfactsfound = True

    return list(set(totfacts))
示例#4
0
def PhiPrimes(n):

  totfacts=[]

  n1 = n-1

  totfacts = RetFact(n1)
  allfactsfound = False

  while allfactsfound == False:
    newfactfound = False
    for m in totfacts:
       o = RetFact(m-1)
       for p in o:
       
         if p<2:continue
         if not p in totfacts:
           totfacts.append(p)
           newfactfound = True
    if newfactfound == False: allfactsfound = True

  return list(set(totfacts))  
lim = 100000  # 10000

# F = FactorSieve(100**3)

a, b, c = 0, 0, 0

cnt = 0

for a in xrange(2, lim, 3):

    x = 8 * a * a * a + 15 * a * a + 6 * a - 1
    if x % 27 == 0:

        x /= 27  #   x = b*b*c
        y = RetFact(x)
        y.append(1)
        y = set(y)
        # print "!",a,y
        for z in y:
            b = z
            c = int(x / (b ** 2))
            # print "!!",x,":",a,b,c
            if x == b * b * c:
                if a + b + c <= 1000:  # 110000000:
                    cnt += 1
                    # print a,b,c

print "Number of Cardano Triplets <=", lim, "is", cnt
print "Process time is", time() - st