In the drawing below we have a part of the Pascal's triangle, lines are numbered from zero (top).
We want to calculate the sum of the squares of the binomial coefficients on a given line with a function called easyline (or easyLine or easy-line).
Can you write a program which calculates easyline(n) where n is the line number?
The function will take n (with: n >= 0) as parameter and will return the sum of the squares of the binomial coefficients on line n.
Examples:
easyline(0)
=> 1
easyline(1)
=> 2
easyline(4)
=> 70
easyline(50)
=> 100891344545564193334812497256
Tests
easyline(7)
easyline(13)
easyline(3)
easyline(19)
Happy Coding!
This challenge comes from g964 on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!
Top comments (4)
Haskell:
From Wikipedia
p.s. I got to use the new latex feature for that!
Python one-liner using recursion
Because,
C++
Little lazy solution using 11 in python3