Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
35
Task/Anti-primes/Python/anti-primes.py
Normal file
35
Task/Anti-primes/Python/anti-primes.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
from itertools import chain, count, cycle, islice, accumulate
|
||||
|
||||
def factors(n):
|
||||
def prime_powers(n):
|
||||
for c in accumulate(chain([2, 1, 2], cycle([2,4]))):
|
||||
if c*c > n: break
|
||||
if n%c: continue
|
||||
d,p = (), c
|
||||
while not n%c:
|
||||
n,p,d = n//c, p*c, d+(p,)
|
||||
yield d
|
||||
if n > 1: yield n,
|
||||
|
||||
r = [1]
|
||||
for e in prime_powers(n):
|
||||
r += [a*b for a in r for b in e]
|
||||
return r
|
||||
|
||||
def antiprimes():
|
||||
mx = 0
|
||||
yield 1
|
||||
for c in count(2,2):
|
||||
if c >= 58: break
|
||||
ln = len(factors(c))
|
||||
if ln > mx:
|
||||
yield c
|
||||
mx = ln
|
||||
for c in count(60,30):
|
||||
ln = len(factors(c))
|
||||
if ln > mx:
|
||||
yield c
|
||||
mx = ln
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(*islice(antiprimes(), 40)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue