[Harshad numbers](http://en.wikipedia.org/wiki/Harshad_number) (also called Niven numbers) are positive numbers that can be divided (without remainder) by the sum of their digits.

For example, the following numbers are Harshad numbers:

* 10, because 1 + 0 = 1 and 10 is divisible by 1
* 27, because 2 + 7 = 9 and 27 is divisible by 9
* 588, because 5 + 8 + 8 = 21 and 588 is divisible by 21

While these numbers are not:

* 19, because 1 + 9 = 10 and 19 is not divisible by 10
* 589, because 5 + 8 + 9 = 22 and 589 is not divisible by 22
* 1001, because 1 + 1 = 2 and 1001 is not divisible by 2

Harshad numbers can be found in any number base, but we are going to focus on base 10 exclusively.

## Your task

Your task is to complete the skeleton Harshad object ("static class") which has 3 functions:

* ```isValid()``` that checks if `n` is a Harshad number or not
* ```getNext()``` that returns the next Harshad number > `n`
* ```getSerie()``` that returns a series of `n` Harshad numbers, optional `start` value not included

You do not need to care about the passed parameters in the test cases, they will always be valid integers (except for the start argument in `getSerie()` which is optional and should default to `0`).

**Note:** only the first 2000 Harshad numbers will be checked in the tests.

## Examples

```python
Harshad.is_valid(1)          ==>  True
Harshad.get_next(0)          ==>  1
Harshad.get_series(3)        ==>  [ 1, 2, 3 ]
Harshad.get_series(3, 1000)  ==>  [ 1002, 1008, 1010 ]
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Mathematics

Starter code: def is_valid(number):
	

Solutions:
from itertools import count, islice

class Harshad:

	@staticmethod
	def is_valid(number):
		return number % sum(map(int, str(number))) == 0

	@classmethod
	def get_next(cls, number):
		return next((i for i in count(number + 1) if cls.is_valid(i)))

	@classmethod
	def get_series(cls, c, start=0):
		return list(islice(filter(cls.is_valid, (i for i in count(start + 1))), c))


class Harshad:

	@staticmethod
	def is_valid(number):
		return number % sum(map(int, str(number))) == 0

	@staticmethod
	def get_next(number):
		n = number + 1
		while not Harshad.is_valid(n):
			n += 1
		return n

	@staticmethod
	def get_series(count, start=0):
		result = [Harshad.get_next(start)]
		for _ in range(count - 1):
			result.append(Harshad.get_next(result[-1]))
		return result


HARSHAD = [n for n in range(1, 13000) if n % sum(map(int, str(n))) == 0]
from bisect import bisect

class Harshad:

	@staticmethod
	def is_valid(n):
		return n in HARSHAD

	@staticmethod
	def get_next(n):
		return HARSHAD[bisect(HARSHAD, n)]

	@staticmethod
	def get_series(cnt, n=0):
		start = bisect(HARSHAD, n)
		return HARSHAD[start:start + cnt]


class Harshad:

	@staticmethod
	def is_valid(number):
		a = list(str(number))
		shu = 0
		for i in a:
			shu += int(i)
		if number % shu == 0:
			return True
		else:
			return False

	@staticmethod
	def get_next(number):
		temp = number
		while 1:
			temp += 1
			if Harshad.is_valid(temp):
				return temp

	@staticmethod
	def get_series(count, start=0):
		result = []
		for i in range(count):
			a = Harshad.get_next(start)
			result.append(a)
			start = a
		return result


class Harshad(object):
	harshad = [n for n in range(1, 12534) if n % sum((int(d) for d in str(n))) == 0]

	@staticmethod
	def is_valid(number):
		return number in Harshad.harshad

	@staticmethod
	def get_next(number):
		return next((n for n in Harshad.harshad if n > number))

	@staticmethod
	def get_series(count, start=0):
		i = Harshad.harshad.index(Harshad.get_next(start))
		return Harshad.harshad[i:i + count]


from itertools import count, islice
D = {}

class Harshad:

	@staticmethod
	def is_valid(number):
		return D.get(number, D.setdefault(number, not number % sum(map(int, str(number)))))

	@staticmethod
	def get_next(number):
		return next(filter(Harshad.is_valid, count(number + 1)))

	@staticmethod
	def get_series(size, start=0):
		return list(islice(filter(Harshad.is_valid, count(start + 1)), size))


class Harshad:

	@staticmethod
	def get_list(n):
		result = []
		while n:
			result.append(n % 10)
			n = n // 10
		result.reverse()
		return result

	@staticmethod
	def is_valid(number):
		if number == 0:
			return False
		if number < 10:
			return True
		num_list = Harshad.get_list(number)
		mul = 0
		for i in num_list:
			mul += i
		if number % mul == 0:
			return True
		else:
			return False

	@staticmethod
	def get_next(number):
		if number < 10:
			return number + 1
		number = number + 1
		while 1:
			if Harshad.is_valid(number) == True:
				break
			number += 1
		return number

	@staticmethod
	def get_series(count, start=0):
		ser_list = []
		start = start + 1
		while 1:
			if Harshad.is_valid(start) == True:
				ser_list.append(start)
			if len(ser_list) == count:
				break
			start += 1
		return ser_list


from bisect import bisect_right

class Harshad:
	(values, values_set) = ([], set())
	i = 1
	while len(values) < 2000:
		if not i % sum((int(x) for x in str(i))):
			values.append(i)
			values_set.add(i)
		i += 1

	@staticmethod
	def is_valid(n):
		return n in Harshad.values_set

	@staticmethod
	def get_next(n):
		return Harshad.values[bisect_right(Harshad.values, n)]

	@staticmethod
	def get_series(n, s=0):
		x = bisect_right(Harshad.values, s)
		return Harshad.values[x:x + n]


class Harshad:

	@staticmethod
	def is_valid(number):
		if number == 0:
			return False
		sumdigits = sum((int(d) for d in str(number)))
		return number % sumdigits == 0

	@staticmethod
	def get_next(number):
		while True:
			number += 1
			if Harshad.is_valid(number):
				return number

	@staticmethod
	def get_series(count, start=0):
		answer = []
		for _ in range(count):
			start = Harshad.get_next(start)
			answer.append(start)
		return answer