Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Comments on Evens or Odds - you know this one

Parent

Evens or Odds - you know this one

+7
−0

Get ready for a comparatively dry question - this is intended to be one of the "the"s of the code-golfing dictionary.

Create a program which inputs a base 10 non-negative whole number (without leading 0s) and outputs something if the number is odd or something else if the number is even.

You MUST input through STDIN unless your language doesn't have input facilities, in which case you may make a function for the purpose.

The odd and even outputs can be whatever you want, so long as the output for a specific parity will stay the same no matter what number of that parity is inputted.

One of the outputs can be absolutely nothing (0 characters) so long as the other output isn't nothing - one or both of the outputs can be printed through STDERR as long as the erroring output is constant for its parity (doesn't change depending on what numbers of a parity you feed it).

Shortest code following the rules wins.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Clarify input and output methods (2 comments)
Post
+4
−0

JavaScript (Node.js), 6 bytes

n=>n%2

Try it online!

Basically does what you'd expect.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

You don't need to count the `f=`. (1 comment)
You don't need to count the `f=`.
Shaggy‭ wrote over 3 years ago

You don't need to count the f=.