I know, you have probably solved this Kata. Moreover there are already answers in comments, but anyway...
2**n this is the for the sum of binominal coefs, but there is another formula for sum of squares.
Note:
In Javascript, Coffeescript, Typescript, C++, PHP, C, R, Nim, Fortran to get around the fact that we have no big integers the function easyLine(n) will in fact return
round(log(easyline(n)))
and not the easyline(n) of the other languages.
So, in Javascript, Coffeescript, Typescript, C++, PHP, R, Nim, C, Fortran:
easyLine(0) => 0
easyLine(1) => 1
easyLine(4) => 4
easyLine(50) => 67
Usually I'd suggest to write the return in the same line after the if instead to better indicate it's an if body that is valid for one line only. Never forget that goto fail bug ;-)
I actually disagree.
I know, you have probably solved this Kata. Moreover there are already answers in comments, but anyway...
2**n this is the for the sum of binominal coefs, but there is another formula for sum of squares.
Please read again: "sum of the SQUARES of the binomial coefficients on a given line"
The sum of the (unsquared) binomial coefficients is 2^n.
Same here. Based on this description and the expected outcome of the examples, I haven't got a clue what to add up.
I'm a mathematician, mind you.
Did you read the description?
(at the bottom of description)
This comment is hidden because it contains spoiler information about the solution
I agree on this one!
And then there's this one. :D
And I may or may not have done something similar with coffee, but that's an even more hazy memory.
ETA: coffee!!
Plain JavaScript
Did you scroll all the way to the right?
Usually I'd suggest to write the
return
in the same line after theif
instead to better indicate it's anif
body that is valid for one line only. Never forget thatgoto fail
bug ;-)