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

Post

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)
Clarify input and output methods
Moshi‭ wrote over 3 years ago

I noticed that there seems to be a pretty wide variety of answers right now. Some of them are functions taking in a number and returning a number. Some of them take from standard input and print to standard output. Some of them are functions that print to standard output.

Could you clarify which of these are the intended method of input and output?

AndrewTheCodegolfer‭ wrote over 3 years ago · edited over 3 years ago

The output may be literally whatever you want through whatever you want so long as the outputs are constant and different, the input has to go through STDIN unless your language doesn't have input, in which case you may use a function.