News for hackers. Stuff that matters.
Re:Code and Trust: Vibrators to Pacemakers by numpad0 on Thursday July 10, 2025 @02:38AM (#44517990)
this doesn't need if statement but 3 variables: nm2 = 0; nm1 = 1; n; f_next(){n = nm1 + nm2; nm2 = nm1; nm1 = n;}

Fibonacci sequence is defined as "F0 = 0, F1 = 1, Fn = F(n-1) + F(n-2)". The author implemented F1 as a special case but it doesn't need to be. That's the weird part.

Re:Code and Trust: Vibrators to Pacemakers by modderation on Thursday July 10, 2025 @04:38AM (#44518732)
It's even more fun when you extend it to negative integers, reals, and the complex plane!

Matt Parker (Stand-up Maths) delves into this in a very approachable manner: https://www.youtube.com/watch?v=ghxQA3vvhsk