1

Building on yesterday's rant (https://devrant.com/rants/3110183/), after sleeping on it I realized that using groups was completely non-necessary, so I got rid of them and got a much more efficient (and faster) function:

Also, I've got these in a repo: https://github.com/chabad360/...

Comments
  • 0
    Is it some backwards fibonacci?

    Also, why do you even use an array when all you need is only a few units to store intermediate values?
  • 1
    @iiii it's regular fibo, I'm just exploring different methods of doing it.

    I need an array, because fibo is O(log n), so I need a way to store all the numbers that need to be fibo'd.
  • 0
    @pseudonim it seems like an incredibly inefficient method to gradually reduce a number into a huge array of ones and zeroes and then add them together.

    BTW, case 0 and case 1 are identical: add to result.
  • 1
    @iiii I'm just having fun mate, yes it's inefficient, I know that. But I'm just trying to stretch my brains to come up with different methods to calculate fibo. I don't think there's anything wrong with a little programming exercise.
  • 0
    @pseudonim to be honest, I'm just amused that such sequence even works as a legit fibonacci calculator.
  • 0
    @iiii why, it does exactly what the recursive fibo does, just it dumps the whole operation on the heap instead.

    There's nothing really special about it, and to my understanding (haven't tested it yet), at large numbers, it could preform just as well (if not better) as the recursive fibo.
  • 1
    @pseudonim you don't need a recursion for fibo >__> just a loop and two "registers"
  • 0
    @iiii mind explaining a bit? I think I get where your going, but I'm a bit to busy to figure it out rn.
  • 3
    @iiii
    "Trampoline" 😋
  • 1
  • 1
    @SortOfTested i don't like that term. non-descriptive. "recursion unwinding" is much better
  • 1
    Actually, I could have removed that check at the top of the function and everything would have worked exactly the same
  • 2
    @iiii
    I don't like a lot terms. Industry do what it do. 😆
  • 2
    @SortOfTested that rant of yours was actually the inspiration for this little experiment.
  • 2
    @pseudonim
    Sometimes it's fun to noodle on rube goldberg machines.

    Who am I kidding, it's always fun.
Add Comment