def factor(x): out = [] if x % 2 == 0: out.append(2) while x % 2 == 0: x /= 2 i = 3 while 1: if x % i == 0: out.append(i) while x % i == 0: x /= i i += 2 if i ** 2 > x: out.append(x) break while out.count(1): out.remove(1) return out def main(same): n = 6 num = 0 while num != same: if len(factor(n)) == same: num += 1 else: num = 0 n += 1 return n maxx = 4 a = main(maxx) for i in xrange(1, maxx + 1): print a - i, factor(a - i)