In the drawing below we have a part of the Pascal's triangle, lines are numbered from **zero** (top).
The left diagonal in pale blue with only numbers equal to 1 is diagonal **zero**, then in dark green 
(1, 2, 3, 4, 5, 6, 7) is diagonal 1, then in pale green (1, 3, 6, 10, 15, 21) is
diagonal 2 and so on.

We want to calculate the sum of the binomial coefficients on a given diagonal.
The sum on diagonal 0 is 8 (we'll write it S(7, 0), 7 is the number of the line where we start, 
0 is the number of the diagonal). In the same way S(7, 1) is 28, S(7, 2) is 56.

Can you write a program which calculate S(n, p) where n is the line where we start and p 
is the number of the diagonal?

The function will take n and p (with: `n >= p >= 0`) as parameters and will return the sum.

## Examples:
```
diagonal(20, 3) => 5985
diagonal(20, 4) => 20349
```
## Hint:
When following a diagonal from top to bottom have a look at the numbers on the diagonal at its right.

## Ref:
http://mathworld.wolfram.com/BinomialCoefficient.html

![alternative text](http://i.imgur.com/eUGaNvIm.jpg)

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def diagonal(n, p):
	

Solutions:
def diagonal(n, p):
	res = 0
	for base in range(p, max(n, p) + 1):
		value = 1
		for i in range(base - p + 1, base + 1):
			value *= i
		for i in range(1, p + 1):
			value //= i
		res += int(value)
	return res


import math

def diagonal(n, p):
	s = 0
	f = math.factorial(p)
	for i in range(n + 1 - p):
		prod = 1
		for j in range(1, p + 1):
			prod *= i + j
		prod = prod // f
		s += prod
	return int(s)


from operator import mul
from functools import reduce

def choose(n, p):
	if p > n - p:
		p = n - p
	return reduce(mul, list(range(n - p + 1, n + 1)), 1) // reduce(mul, list(range(1, p + 1)), 1)

def diagonal(n, p):
	return choose(n + 1, p + 1)


from math import factorial

def diagonal(n, p):
	return factorial(n + 1) // (factorial(p + 1) * factorial(n - p))


def diagonal(line, diag):
	(s, j, p) = (1, 1, 1)
	for i in range(diag + 1, line + 1):
		p = p * i // j
		s += p
		j += 1
	return s


from functools import reduce

def comb(n, p):
	(a, b) = (n - p, p)
	return reduce(lambda x, y: x * y, range(max(a, b) + 1, n + 1)) // reduce(lambda x, y: x * y, range(1, min(a, b) + 1))

def diagonal(n, p):
	return comb(n + 1, p + 1)


from math import factorial

def diagonal(n, p):
	s = factorial(n + 1) // (factorial(p + 1) * factorial(n - p))
	return int(s)


from functools import reduce
from operator import mul
from fractions import Fraction as frac

def diagonal(n, p):
	return reduce(mul, [frac(n + 1 - k, k + 1) for k in range(p + 1)], 1)