News for hackers. Stuff that matters.
Re:Code and Trust: Vibrators to Pacemakers by tzs on Thursday July 10, 2025 @12:30AM (#44517180)
> This program will vibrate with increase frequency using the Fibonacci numbers 2, 3, 5, 8, 13, 21, 34..

No it won't. The sequence it follows is 2, 1, 1, 1, ...

After spotting that I was curious if LLMs would also spot it. I asked Perplexity this and gave it the code:

> This is Python code someone posted for a hypothetical vibrator. They said it will vibrate with increasing frequency following Fibonacci numbers: 2, 3, 5, 8, ...

> Does the frequency really increase following that sequence?

It correctly found the actual sequence, explained why the code fails, and offered a fix.

Re:Code and Trust: Vibrators to Pacemakers by maxbond on Thursday July 10, 2025 @01:42AM (#44517665)
> The sequence it follows is 2, 1, 1, 1, ...

I just ran it, and as long as you start counting at 1, their code works fine, outputting `1, 1, 2, 3, 5, ...`. (Not sure why they say the Fibonacci sequence starts with 2, that's odd.)

Re:Code and Trust: Vibrators to Pacemakers by amluto on Thursday July 10, 2025 @01:50AM (#44517704)
One can reasonably debate where the Fibonacci sequence starts. Their fib implementation is unquestionably broken for negative inputs, but fortunately they don’t supply negative inputs.

But try reading the code that calls fib. It’s so outrageously wrong that it’s fairly easy to read it and pretend they wrote something sensible. Never mind that there isn’t actually a straightforward single-line fix - next_fib would be an entirely different beast from fib.

If they had started with frequency = 4, the real effect of the code would have been to send a couple pulses and then to spend very rapidly (worse than exponentially) increasing time and stack space trying to compute fib.

Re:Code and Trust: Vibrators to Pacemakers by maxbond on Thursday July 10, 2025 @01:54AM (#44517734)
I had missed that, thanks. That is whack. (The input to fibonacci() is it's last output.)
Re:Code and Trust: Vibrators to Pacemakers by maxbond on Sunday July 13, 2025 @04:33AM (#44548578)
This doesn't really matter but it does occur to me that you can't really reasonably debate where the Fibonacci sequence starts, because if it started at 2, then 1 wouldn't be a Fibonacci number. But indeed, it's not only a Fibonacci number, but the only one to be in the sequence twice. (You can of course skip ahead if you have some need to do so.)
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

Re:Code and Trust: Vibrators to Pacemakers by kh_hk on Thursday July 10, 2025 @12:35AM (#44517219)
Weird, after the fix vibrator sleeps the longer it is used. Also, at some point it burst into flames
Re:Code and Trust: Vibrators to Pacemakers by jackdoe on Thursday July 10, 2025 @02:50AM (#44518069)
ah, i fixed it, i wasn't actually thinking about the code when writing it, didnt even try it :facepalm: absolute brainfart haha I guess it makes the transparency point even stronger
Re:Code and Trust: Vibrators to Pacemakers by Onavo on Thursday July 10, 2025 @01:56AM (#44517742)
Now ask the the AI to write a formal verification program to prove it :)