Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
atheist94707yPhp I think? I'm not a php dev. Also looks like you're calculating some form of approximation of the fib sequence, reference?
-
Crazed20507yI was listening to a podcast recently that mentioned that a lot of people try hard to do something clever that they lose sight of the goal of the code and end up with use case scenario errors or problems with readability...
Especially the latter. -
Crazed20507y@araxhiel I believe it was the full stack podcast, or one of those more popular ones, in the first episode about CSS. Yeahhh that was definitely it, he spoke of some dev creating massive lists of selectors using mixins for a single style haha
-
@jmclemo6 for obfuscation. (Hint: $ === Math)
@alwaysmpe it looked like js to me, then I noticed the tag. It's js. -
nukasev4857y@alwaysmpe
actually there is an explicit/closed-form formula for Nth Fibonacci number which does not include recursion.
after quick googling for proof: http://community.wvu.edu/~krsubrama... -
ClySuva19257y@jmclemo6 it's javascript. $ sign is aliased to Math so you wouldn't have to write Math.pow, Math.sqrt
-
ClySuva19257y@alwaysmpe it's the closed form solution for Fibonacci number, aka the Binet's Formula.
-
purist12167yNice.... Most people wont understand this..but it gives you a chance to show them ur mathematical prowess...
-
purist12167yTo all those who dont get it.. This uses the golden ratio..that is (1+/-sqrt(5))/2..Powers of the golden ratio gives nth fibonacci number..
-
nukasev4857y@aEEEdev fun fact: limit of fibo(n+1)/fibo(n) approaches the golden ratio. It is known. :)
-
@theCreativeOne no dude, it's Math in this case. $ here is a function argument, and that function is being called with Math.
-
jmclemo66807y@shellbug ah, I saw the js tags and dollar signs, thought it was jquery, and immediately thought of this https://stackoverflow.com/a/...
-
purist12167y@nukasev I didnt say it was a forbidden secret.. Not many know that golden ratios has got something to do with fibonacci numbers.. By the way ur statement and mine doesnt make much difference..Both are almost the same..
Related Rants
At a job interview.
Them: Can you please write a function that calculates fibonacci numbers on the whiteboard please.
Me:
fib=_=>($=>$.round(($.pow((1+$.sqrt(5))/2,_)-$.pow(-2/(1+$.sqrt(5)),_))/$.sqrt(5)))(Math)
undefined
math
obfuscated
whiteboard interview
js
whiteboard
job interview