Program to output a subset of the composite numbers

Peter Otten __peter__ at web.de
Wed Aug 15 15:08:27 EDT 2018


tomusatov at gmail.com wrote:

> Thank you very much! Do you also know how I might slightly alter to
> composite numbers that are one less than twice a composite number?
> 
> 15 would be the first number
> Since 8 is composite then
> 
> 2*8=16
> 16 - 1=15 Is composite

Like

>>> def is_composite(n):
...     return not is_prime(n)
... 
>>> print(list(islice((i for i in count(3, step=2) if is_composite(i) and 
is_composite((i+1)//2)), 20)))
[15, 27, 35, 39, 49, 51, 55, 63, 65, 69, 75, 77, 87, 91, 95, 99, 111, 115, 
119, 123]

?




More information about the Python-list mailing list