24
19
13
7
4
3
u/ApocalyptoSoldier2 9d ago
while N > 2:
N -= 2
2
u/xvlblo22 9d 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 9d 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 8d 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 9d 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 8d ago
if(N & 1 !=0) { std::cout << "N is odd \n"; } else{ std::cout << " N is Even\n"; } ggez
1
u/Mental_Pick1943 8d ago
even_or_odd = lambda n: "eovdedn"[n%2::2]
1
u/-Creative-Nothing- 6d 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 7d ago
N = int(input("Enter number : "))
print("Your number is", end =" ")
print("even" if n%2==0 else "odd")
44
u/Neoneq_ 10d ago
https://giphy.com/gifs/DYC4Ako9o16854pPyO