DEV Community

p4nd3m1c
p4nd3m1c

Posted on

Did I Just Accidentally Beat Fibonacci?

Did I Just Accidentally Beat Fibonacci?

  • spoiler: I did'nt!

  • Ok so, yesterday I was brain storming some algorithms and suddendly a spark in my stupid brain lurked(somewhat), I accidentlly invented a new AND BETTER fib algo!

  • So here it goes:

  • fib is what: addition of all numbers from 1..n. (whats what i thought LOL)

So why not just: (n+1) * (n/2) if n is even? and n * (n/2) when odd? BOY I WAS HAPPY!

  • And I tested the fib of 10, and it printed 55, VOILA!
  • I tested it some other algos, and it was faster the nthe fastest one by 1,200,000%, and yep then it hit me!

  • it only computes fib of some numbers and not others!

Now i am sad! AAHAHAHAHAHAHHHHHH

Top comments (0)