num_list = {} n_list = {} index = 0 n = 0 for i in range(4, 10): for j in range(4, 10): for k in range(4, 10): for a in range(4, 10): if i != j and i != k and i != a and j != k and j != a and k != a: num_list[index] = i * 1000 + j * 100 + k * 10 + a index = index + 1 for m in num_list: x = num_list[m] for z in range(2, x): if x % z == 0: break else: n_list[n] = x n = n + 1 print("所有组合的数是 %s" % num_list) print("共有 %d 个" % len(num_list)) print("所有质数是 %s" % n_list) print("共有 %d 个" % len(n_list))