Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
20
Task/Pernicious-numbers/Python/pernicious-numbers.py
Normal file
20
Task/Pernicious-numbers/Python/pernicious-numbers.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
>>> def popcount(n): return bin(n).count("1")
|
||||
|
||||
>>> primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61}
|
||||
>>> p, i = [], 0
|
||||
>>> while len(p) < 25:
|
||||
if popcount(i) in primes: p.append(i)
|
||||
i += 1
|
||||
|
||||
|
||||
>>> p
|
||||
[3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 31, 33, 34, 35, 36]
|
||||
>>> p, i = [], 888888877
|
||||
>>> while i <= 888888888:
|
||||
if popcount(i) in primes: p.append(i)
|
||||
i += 1
|
||||
|
||||
|
||||
>>> p
|
||||
[888888877, 888888878, 888888880, 888888883, 888888885, 888888886]
|
||||
>>>
|
||||
Loading…
Add table
Add a link
Reference in a new issue