%time # python 2.6.X, sage 4.5.2, seq id:A059404 from os.path import expanduser lo = 2 hi = 3 * 10^4 mixed = [] for a in xrange(lo,hi+1): if is_prime(a): # very fast check for a < 2^64 continue lst = list(factor(a)) if len(lst)==1: continue firste = lst[0][1] if any(map(lambda b:b[1]!=firste, lst)): mixed.append(a) with open(expanduser("~/B059404.txt"), 'w') as fp: for i in xrange(10^4): print >> fp, "%d %d" % (i+1, mixed[i]) fp.close() del(fp)