-
Notifications
You must be signed in to change notification settings - Fork 0
/
A322529.py
33 lines (29 loc) · 1.2 KB
/
A322529.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /usr/bin/env python3
from labmath import partgen, primefac, count
print(0, 1)
for n in count(1):
total = 0
for party in partgen(n):
# Of those partitions that are counted by this sequence, only the all-ones partitions can contain ones.
# The lists yielded by partgen have their terms in increasing order.
# Therefore, the following line is not necessary, but speeds things up.
if party[0] == 1 and party[-1] != 1: continue
flag = False # This will be set to True if a partition turns out to be bad.
factors = set()
factorcount = len(list(primefac(party[0])))
for part in party:
omega = 0
for p in primefac(part):
if p in factors:
flag = True # A factor is repeated.
break
factors.add(p)
omega += 1
if omega > factorcount:
flag = True # Not all parts have the same number of factors.
break
if omega != factorcount: flag = True # Not all parts have the same number of factors.
if flag: break
if flag: continue
total += 1
print(n, total)