1051
they call it gen z c++ (sh.itjust.works)
you are viewing a single comment's thread
view the rest of the comments
[-] rockSlayer@lemmy.world 31 points 1 year ago

I was following along until the bussin loop. What is it trying to yeet?

[-] scutiger@lemmy.world 15 points 1 year ago

yeet cap rn

It's right there!

[-] aaaa@lemmy.world 14 points 1 year ago* (last edited 1 year ago)

I believe it outputs the prime factors of the number you gave it.

The yeet value is just specifying if the function succeeded or not

[-] vahtos@programming.dev 14 points 1 year ago

I found this amusing enough to try it out. It does actually compile (I used g++ for this). However, the current implementation just goes into an infinite loop if you enter a number >= 2.

I think the original author meant to do n -= 1 rn in the tweakin loop that is inside the bussin loop. That way, at some point n % i finna cap will be false, and i will bouta. Which then makes the expression i <= n in the bussin loop eventually false, so we stop bussin and yeet cap rn.

However, that would mean that the intention of the program isn't to output prime factors, because even with this fix it does not do so. The structure of mf chief() also doesn't suggest that is the purpose as it is missing another tweakin and sussin like this example of calculating prime factors in C++.

Example run:

$ ./zpp.exe
Enter a number larger than 1: 50
2
7
8
47
[-] aaaa@lemmy.world 7 points 1 year ago

Yeah it definitely looks like a flawed implementation either way. Probably a student got bored of trying to make it work, and went nuts with the #defines for fun

As a career programmer myself.... I can absolutely relate.

[-] LoafyLemon@kbin.social 6 points 1 year ago

Returns a zero, I think.

this post was submitted on 27 Jul 2023
1051 points (96.5% liked)

Programmer Humor

31995 readers
129 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS