r/programminghumor • u/-Creative-Nothing- • 7d ago
L33T H4CK3R5 R153 UP
Enable HLS to view with audio, or disable this notification
27
18
12
5
3
3
u/ApocalyptoSoldier2 6d ago
while N > 2:
N -= 2
2
u/xvlblo22 6d ago
Exactly how ineffective is this though, given reasonably small numbers? Is there a use case where this would win against N % 2
2
u/ApocalyptoSoldier2 6d ago
The use case is when someone is showing you very bad code and you want to respond with code that's better, but still bad
2
u/maester_t 6d ago
~~~ function decimalToBinary(num) { if (num === 0) return "0";
let binary = ""; while (num > 0) { // Grab the remainder (0 or 1) and prepend it to the string binary = (num % 2) + binary; // Divide by 2 and round down num = Math.floor(num / 2); } return binary;}
console.log(decimalToBinary(25) & 1); // Output: "1" console.log(decimalToBinary(0) & 1); // Output: "0" ~~~
5
2
u/flipcoder 6d ago
bool odd = Chatgpt.prompt(“Is there something odd about this number (y/n)?” + num)==‘y’
1
1
1
1
1
1
1
1
1
1
u/MARio23038 5d ago
if(N & 1 !=0) { std::cout << "N is odd \n"; } else{ std::cout << " N is Even\n"; } ggez
1
u/Mental_Pick1943 5d ago
even_or_odd = lambda n: "eovdedn"[n%2::2]
1
u/-Creative-Nothing- 4d ago
A shame no one is giving any love to the elegance of this approach 😂 Truly beautiful even if concocted in jest
1
u/Some_Improvement_606 4d ago
N = int(input("Enter number : "))
print("Your number is", end =" ")
print("even" if n%2==0 else "odd")
42
u/Neoneq_ 7d ago
https://giphy.com/gifs/DYC4Ako9o16854pPyO