Write a function generator that will generate the first `n` primes grouped in tuples of size `m`. If there are not enough primes for the last tuple it will have the remaining values as `None`.

## Examples

```python
For n = 11 and m = 2:
(2, 3), (5, 7), (11, 13), (17, 19), (23, 29), (31, None)

For n = 11 and m = 3:
(2, 3, 5), (7, 11, 13), (17, 19, 23), (29, 31, None)

For n = 11 and m = 5:
(2, 3, 5, 7, 11), (13, 17, 19, 23, 29), (31, None, None, None, None)]

For n = 3 and m = 1:
(2,), (3,), (5,)
```

Note: large numbers of `n` will be tested, up to 50000

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def get_primes(how_many, group_size=2):
	

Solutions:
LIMIT = 10 ** 6
sieve = [0] * 2 + list(range(2, LIMIT))
for n in sieve:
	if n:
		for i in range(n * n, LIMIT, n):
			sieve[i] = 0
PRIMES = list((n for n in sieve if n))

def get_primes(n, m=2):
	primes_ = PRIMES[:n] + [None] * m
	return (tuple(primes_[i:i + m]) for i in range(0, n, m))


primes = [2, 3, 5, 7, 11]

def gen_primes():
	yield from primes
	candidate = primes[-1]
	candidate_root = int(candidate ** 0.5) + 1
	while True:
		candidate += 2
		if candidate_root * candidate_root < candidate:
			candidate_root += 1
		for p in primes:
			if candidate % p == 0:
				break
			if p > candidate_root:
				primes.append(candidate)
				yield candidate
				break

def get_primes(how_many, group_size=2):
	result = []
	for (i, p) in enumerate(gen_primes(), start=1):
		result.append(p)
		if len(result) == group_size:
			yield tuple(result)
			result = []
		if i == how_many:
			break
	if len(result) > 0:
		while len(result) < group_size:
			result.append(None)
		yield tuple(result)


from itertools import zip_longest
import math

def get_primes(how_many, group_size=2):
	if how_many > 0:
		pr = primes(how_many)
		yield from [tuple(e) for e in zip_longest(*[iter(pr)] * group_size)]

def is_prime(n):
	return all((n % i for i in range(3, int(math.sqrt(n)) + 1, 2)))

def primes(n):
	(i, pr) = (3, [2])
	while n > 1:
		if is_prime(i):
			n -= 1
			pr.append(i)
		i += 2
	return pr


from itertools import compress, islice, zip_longest
import numpy as np
s = np.ones(1000000)
s[:2] = s[4::2] = 0
for i in range(3, int(len(s) ** 0.5) + 1, 2):
	if s[i]:
		s[i * i::i] = 0
primes = list(compress(range(len(s)), s))

def get_primes(how_many, group_size=2):
	yield from zip_longest(*[islice(primes, how_many)] * group_size)


def get_primes(how_many, group_size):
	primes = [False] * 2 + list(range(2, 13 * how_many))
	for x in primes:
		if x:
			for i in range(x * x, 13 * how_many, x):
				primes[i] = False
	seq = sorted(set(primes))[1:how_many + 1]
	while len(seq) % group_size != 0:
		seq += [None]
	return (tuple(seq[x:x + group_size]) for x in range(0, len(seq), group_size))


def makePrimes(n):
	(sieve, primes) = ([0] * (n + 1), [])
	for i in range(2, n + 1):
		if not sieve[i]:
			primes.append(i)
			for j in range(i ** 2, n + 1, i):
				sieve[j] = 1
	return primes
PRIMES = makePrimes(650000)

def get_primes(how_many, group_size=2):
	lst = PRIMES[:how_many] + [None] * (group_size - how_many % group_size)
	for n in range(how_many // group_size + bool(how_many % group_size)):
		yield tuple(lst[n * group_size:(n + 1) * group_size])


import gmpy2

def get_primes(how_many, group_size):
	n = 2
	count = 0
	while count < how_many:
		res = []
		for i in range(group_size):
			res.append(int(n) if count < how_many else None)
			n = gmpy2.next_prime(n)
			count += 1
		yield tuple(res)


from itertools import islice, chain, repeat

def gen_primes():
	D = {}
	q = 2
	while True:
		if q not in D:
			yield q
			D[q * q] = [q]
		else:
			for p in D[q]:
				D.setdefault(p + q, []).append(p)
			del D[q]
		q += 1

def get_primes(how_many, group_size=2):
	return (t for t in zip(*[chain(islice(gen_primes(), how_many), repeat(None, group_size - 1))] * group_size))


get_primes = lambda n, m: (tuple(g) for g in zip(*[iter([2] + [p for p in range(3, 15 * n, 2) if all((p % d for d in range(3, int(p ** 0.5) + 1, 2)))][:n - 1] + [None] * (m - 1))] * m))


import itertools

def prime(a):
	return not (a < 2 or any((a % x == 0 for x in range(2, int(a ** 0.5) + 1))))

def get_primes(how_many, group_size=2):
	primes = filter(prime, itertools.count(2))
	yield from itertools.zip_longest(*[itertools.islice(primes, how_many)] * group_size)