I am more amazed that he didn't stop at 10 and think "damn this is tiresome isn't there a one liner i could do?". I want to know how far he went. His stubbornness is amazing but also scary. I haven't seen this kind of code since back in school lol lol lol
Programmer Humor
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
You could use a loop to subtract 2 from the number until it equals one or zero
Good if you are rated by an AI that pays for LOCs.
When did Thor become the dev for Yandere Simulator?
that's some good code right there
To be fair, the question is "Write a function that simultaneously determines if the number is even and works as a timer"
sleepSort meets sleepIsEven
I hope that the language's int
s are at most 32 bits. For 8 bits it could even be written by hand & the source code for a 32 bit version would only take up avg_line_len * 4GiB
space for the source code of the function. But it might take a bit of time to compile a version that supports the full range of 64 or 128 bit ints.
My mate, Paul, says all numbers after 700 repeat so we can stop there.
We just give them different names so you think they're going up.
Yeah but did you know he worked for Blizzard tho
private bool isEven(int number){
bool result = true;
while (number > 0){
number = number - 1;
if (result == true)
result = false;
else
result = true;
}
return result;
}
(P.S.: Only works for positive numbers)
This works for both positive and negative numbers:
private static bool isEven(int number)
{
bool result = true;
while (number < 0)
{
number = number - 1;
if (result == true)
result = false;
else
result = true;
}
while (number > 0)
{
number = number - 1;
if (result == true)
result = false;
else
result = true;
}
return result;
}
Output:
isEven(4) = True
isEven(5) = False
isEven(-4) = True
isEven(-5) = False