Post History
Python, 98 bytes from itertools import* f=lambda n:[*islice(filter(lambda k:k%sum(map(int,str(k)))==0,count(1)),n)] itertools.count() generates integer numbers starting from 1, filter() fil...
Answer
#3: Post edited
# Python, 101 bytes- ```python
- from itertools import*
f=lambda n:list(islice(filter(lambda k:k%sum(map(int,str(k)))==0,count(1)),n))- ```
- * `itertools.count()` generates integer numbers starting from 1,
- * `filter()` filters out the Niven numbers,
- * `itertools.islice()` limits the result to `n` items,
* and `list()` collects the numbers in a list.
- # Python, 98 bytes
- ```python
- from itertools import*
- f=lambda n:[*islice(filter(lambda k:k%sum(map(int,str(k)))==0,count(1)),n)]
- ```
- * `itertools.count()` generates integer numbers starting from 1,
- * `filter()` filters out the Niven numbers,
- * `itertools.islice()` limits the result to `n` items,
- * and `[*...]` collects the numbers in a list.
#2: Post edited
# Python, 113 bytes- ```python
from itertools import count,islice- f=lambda n:list(islice(filter(lambda k:k%sum(map(int,str(k)))==0,count(1)),n))
- ```
- * `itertools.count()` generates integer numbers starting from 1,
- * `filter()` filters out the Niven numbers,
- * `itertools.islice()` limits the result to `n` items,
- * and `list()` collects the numbers in a list.
- # Python, 101 bytes
- ```python
- from itertools import*
- f=lambda n:list(islice(filter(lambda k:k%sum(map(int,str(k)))==0,count(1)),n))
- ```
- * `itertools.count()` generates integer numbers starting from 1,
- * `filter()` filters out the Niven numbers,
- * `itertools.islice()` limits the result to `n` items,
- * and `list()` collects the numbers in a list.
#1: Initial revision
# Python, 113 bytes ```python from itertools import count,islice f=lambda n:list(islice(filter(lambda k:k%sum(map(int,str(k)))==0,count(1)),n)) ``` * `itertools.count()` generates integer numbers starting from 1, * `filter()` filters out the Niven numbers, * `itertools.islice()` limits the result to `n` items, * and `list()` collects the numbers in a list.