title: Is this even or odd?

text:
# Question
Title: Is this even or odd?
> *Note: There is not been a vanilla parity test challenge yet (There is a C/C++ one but that disallows the ability to use languages other than C/C++, and other non-vanilla ones are mostly closed too), So I am posting one.*

Given a positive integer, output its parity (i.e. if the number is odd or even) in truthy/falsy values. You may choose whether truthy results correspond to odd or even inputs.

---

# Examples

Assuming True/False as even and odd (This is not required, You may use other Truthy/Falsy values for each), responsively:

```
(Input):(Output)
1:False
2:True
16384:True
99999999:False

```

# Leaderboard

```
var QUESTION_ID=113448,OVERRIDE_USER=64499;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){var F=function(a){return a.lang.replace(/<\/?a.*?>/g,"").toLowerCase()},el=F(e),sl=F(s);return el>sl?1:el<sl?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```

```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```

# Answer
# ArnoldC, ~~299~~ 283 bytes

```
IT'S SHOWTIME
HEY CHRISTMAS TREE i
YOU SET US UP 0
GET YOUR ASS TO MARS i
DO IT NOW
I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY
GET TO THE CHOPPER i
HERE IS MY INVITATION i
I LET HIM GO 2
ENOUGH TALK
TALK TO THE HAND i
YOU HAVE BEEN TERMINATED

```

This outputs `1` (which is truthy) for odd input and `0` (which is falsy) for even input.

**Try it online!**

## Now this is the plan” (An attempt at an explanation)

The code reads the input into variable `i`, replaces it with the result of modulo 2, and then prints it.

```
IT'S SHOWTIME                                    # BeginMain
HEY CHRISTMAS TREE i                             #   Declare i
YOU SET US UP 0                                  #   SetInitialValue 0
GET YOUR ASS TO MARS i                           #   AssignVariableFromMethodCall i
DO IT NOW                                        #   CallMethod
I WANT TO ASK YOU ... ANSWERED IMMEDIATELY       #   ReadInteger
GET TO THE CHOPPER i                             #   AssignVariable i
HERE IS MY INVITATION i                          #     SetValue i (push i on the stack)
I LET HIM GO 2                                   #     ModuloOperator 2
ENOUGH TALK                                      #   EndAssignVariable
TALK TO THE HAND i                               #   Print i
YOU HAVE BEEN TERMINATED                         # EndMain

```
> 131 votes

# Answer
# brainfuck, 8 bytes

```
+[,>,]<.

```

Input is in unary. Output is the **1** (truthy) for odd numbers and **NUL** (falsy) for even numbers.

Try it online!

### How it works

We start by incrementing the current cell with `+` to be able to enter the while loop `[,>,]`.

In each iteration, `,` reads a byte from STDIN, `>` advances to the cell to the right, then `,` reads another byte from STDIN. When input is exhausted, the interpreter (the one on TIO, anyway) will set the cell to **NUL** instead. Once that happens, the condition of the while loop is no longer fulfilled and we break out of it.

Let **n** be the input integer. If there is an even amount of input bytes – i.e., if **n** is even – the first **n/2** iterations will read two **1**'s, and the next iteration will read two **NUL**'s, leaving the tape as follows.

```
...   1  NUL  NUL
...  49    0    0
                ^

```

`<.` retrocedes one cell and prints its content, sending a **NUL** byte to STDOUT.

However, if there is an odd amount of input bytes, the first **(n - 1)/2** iterations will read two **1**'s, and the next iteration will read one **1** and one **NUL**, leaving the tape as follows.

```
...   1    1  NUL
...  49   49    0
                ^

```

`<` will now retrocede to a cell holding the byte/character **1**, which `.` prints.
> 52 votes

# Answer
## Mathematica, 4 bytes

```
OddQ

```

Gives `True` for odd inputs and `False` for even inputs, who knew?

There's also `EvenQ`, but who would want to type all of that?
> 41 votes

# Answer
# Taxi, ~~1,482~~ ~~1,290~~ ~~1,063~~ ~~1,029~~ 1,009 bytes

I've never written a program in Taxi before and I'm a novice in programming for general, so there are probably better ways to go about this. I've checked for errors and managed to golf it a bit by trying different routes that have the same result. I welcome any and all revision.

Returns `0` for even and `1` for odd.

```
Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:s 1 l 1 r.Pickup a passenger going to Divide and Conquer.2 is waiting at Starchild Numerology.Go to Starchild Numerology:n 1 l 1 l 1 l 2 l.Pickup a passenger going to Divide and Conquer.Go to Divide and Conquer:e 1 l 2 r 3 r 2 r 1 r.Pickup a passenger going to Cyclone.Go to Cyclone:e 1 l 1 l 2 l.Pickup a passenger going to Trunkers.Pickup a passenger going to Equal's Corner.Go to Trunkers:s 1 l.Pickup a passenger going to Equal's Corner.Go to Equal's Corner:w 1 l.Switch to plan "b" if no one is waiting.Pickup a passenger going to Knots Landing.Go to Knots Landing:n 4 r 1 r 2 r 1 l.[a]Pickup a passenger going to The Babelfishery.Go to The Babelfishery:w 1 l.Pickup a passenger going to Post Office.Go to Post Office:n 1 l 1 r.[b]0 is waiting at Starchild Numerology.Go to Starchild Numerology:n 1 r.Pickup a passenger going to Knots Landing.Go to Knots Landing:w 1 r 2 r 1 r 2 l 5 r.Switch to plan "a".

```

Try it online!

You're right, that's awful to read without line breaks. Here's a formatted version:

```
Go to Post Office:w 1 l 1 r 1 l.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery:s 1 l 1 r.
Pickup a passenger going to Divide and Conquer.
2 is waiting at Starchild Numerology.
Go to Starchild Numerology:n 1 l 1 l 1 l 2 l.
Pickup a passenger going to Divide and Conquer.
Go to Divide and Conquer:e 1 l 2 r 3 r 2 r 1 r.
Pickup a passenger going to Cyclone.
Go to Cyclone:e 1 l 1 l 2 l.
Pickup a passenger going to Trunkers.
Pickup a passenger going to Equal's Corner.
Go to Trunkers:s 1 l.
Pickup a passenger going to Equal's Corner.
Go to Equal's Corner:w 1 l.
Switch to plan "b" if no one is waiting.
Pickup a passenger going to Knots Landing.
Go to Knots Landing:n 4 r 1 r 2 r 1 l.
[a]Pickup a passenger going to The Babelfishery.
Go to The Babelfishery:w 1 l.
Pickup a passenger going to Post Office.
Go to Post Office:n 1 l 1 r.
[b]0 is waiting at Starchild Numerology.
Go to Starchild Numerology:n 1 r.
Pickup a passenger going to Knots Landing.
Go to Knots Landing:w 1 r 2 r 1 r 2 l 5 r.
Switch to plan "a".

```

Here's my best attempt to explain the logic:

```
Go to Post Office to pick up the stdin value in a string format.
Go to The Babelfishery to convert the string to a number.
Go to Starchild Numerology to pickup the numerical input 2.
Go to Divide and Conquer to divide the two passengers (stdin & 2).
Go to Cyclone to create a copy of the result.
Go to Trunkers to truncate the original to an integer.
Go to Equal's Corner to see if the two passengers are the same.
Equal's Corner returns the first passenger if they're the same (no .5 removal so the stdin was even) or nothing if they're not.
If nothing was returned, it was odd, so go pick up a 0 from Starchild Numerology.
Go to Knots Landing to convert any 0s to 1s and all other numbers to 0s.
Go to The Babelfishery to convert the passenger (either a 1 or 0 at this point) to a string.
Go to Post Office to print that string.
Try and fail to go to Starchild Numerology because the directions are wrong so the program terminates.

```

Not going back to the Taxi Garage causes output to STDERR but I'm fine with that.
> 32 votes

# Answer
# Python, ~~11~~ 10 bytes

-1 byte thanks to Griffin

```
1 .__and__

```

Try it online!
Using bitwise `and`, returns `0` for even and `1` for odd
> 26 votes

# Answer
## Retina, 8 bytes

```
[02468]$

```

A Retina answer for decimal input. This is also a plain regex solution that works in almost any regex flavour. Matches (and prints `1`) for even inputs and doesn't match (and prints `0`) for odd inputs.

Try it online!

An alternative, also for 8 bytes, uses a transliteration stage to turn all even digits to `x` first (because transliteration stages have a built-in for even/odd digits):

```
T`E`x
x$

```

Of course, the shortest input format (even shorter than unary) would be binary in this case, where a simple regex of `0$` would suffice. But since the challenge is essentially about finding the least-signficant binary digit, binary input seems to circumvent the actual challenge.
> 25 votes

# Answer
## LOLCODE, 67 bytes

```
HOW DUZ I C YR N
  VISIBLE BOTH SAEM MOD OF N AN 2 AN 0
IF U SAY SO

```

Function that returns `WIN` (true) if number is even, else (odd) it will return `FAIL` (false).

Call with `C"123"`.
> 23 votes

# Answer
# MATL, ~~5~~ 3 bytes

*Because builtins are boring*

```
:He

```

This outputs a matrix of nonzero values (which is truthy) for even input, and a matrix with a zero in its lower right entry (which is falsy) for odd input.

**Try it online!** The footer code is an `if-else` branch to illustrate the truthiness or falsihood of the result. Removing that footer will implicitly display the matrix.

### Explanation

Consider input `5` as an example

```
:     % Implicitly input n. Push row vector [1 2 ... n]
      % STACK: [1 2 3 4 5]
He    % Reshape into a 2-row matrix, padding with zeros if needed
      % STACK: [1 3 5;
                2 4 0]

```
> 21 votes

# Answer
# Java 8, 8 bytes

```
n->n%2<1

```

Try it here.

# Java 7, 30 bytes

```
Object c(int n){return n%2<1;}

```

Try it here.

Outputs `true` for even numbers and `false` for odd numbers

---

If `1/0` would be allowed instead of `true/false` (it isn't, considering the numbers of votes here):

* **Java 8 (6 bytes):** `n->n%2`
* **Java 7 (25 bytes):** `int c(int n){return n%2;}`
> 19 votes

# Answer
# Piet, 15 codels / 16 bytes

```
5njaampjhompppam

```

Online interpreter available here.

This program returns 0 if the input is even and 1 if the input is odd.

The text above represents the image. You can generate the image by pasting it into the text box on the interpreter page. For convenience I have provided the image below where the codel size is 31 pixels. The grid is there for readability and is not a part of the program.

## Explanation

This program uses the modulo builtin to determine if the input is even or odd.

```
Instruction    Δ Hue   Δ Lightness   Stack
------------   -----   -----------   -------
In (Number)    4       2             n
Push [2]       0       1             2, n
Modulo         2       1             n % 2
Out (Number)   5       1             [Empty]
[Exit]         [N/A]   [N/A]         [Empty]

```

The dark blue codels in the bottom-left are never visited and can be changed to any color other than a color of a neighboring codel. I chose dark blue as I think it looks nice with the rest of the program. The top-left black codel could also be white, but not any other color. I have chosen black as I think it looks nicer.

I have provided the program in both image form and text form as there is no clear consensus on how to score Piet programs. Feel free to weigh in on the meta discussion.
> 17 votes

# Answer
# brainfuck, 14 bytes

Input and output is taken as character codes as per this meta.
Byte value 1 correspond to odd numbers and 0 to even.

```
+>>,[-[->]<]<.

```

Try it online!
> 15 votes

# Answer
# JavaScript, 6 bytes

An anonymous function:

```
n=>n&1

```

Alternatively with the same length:

```
n=>n%2

```

Both will return `0|1` which should fulfill the requirement for `truthy|falsey` values.

Try both versions online
> 15 votes

# Answer
# Japt, 1 byte

```
v

```

Returns `1` for even numbers, `0` for odd.

Try it online!

### Explanation

One of Japt's defining features is that unlike most golfing languages, functions do not have fixed arity; that is, any function can accept any number of arguments. This means that you can sometimes leave out arguments and Japt will guess what you want. `v` on numbers is a function that accepts one argument and returns `1` if the number is divisible by the argument, else `0`. For example:

```
v3

```

This program will output `1` if the input is divisible by 3, and `0` otherwise. It just so happens that the default argument is `2`, thereby solving this challenge in a single byte.

---

## Alternative 1 byte solution:

```
¢

```

`¢` converts the input into a base-2 string. The `-h` flag returns the last char from the string.

Try it online!
> 14 votes

# Answer
# Sinclair ZX81 BASIC 124 bytes 114 bytes 109 bytes 57 50 42 tokenized BASIC bytes

Another release candidate:

```
 1 INPUT A
 2 IF A THEN PRINT A;":";NOT INT A-(INT (INT A/VAL "2")*VAL "2")

```

As per Adám's comments below:

```
 1 INPUT A
 2 IF NOT A THEN STOP
 3 PRINT A;":";NOT INT A-(INT (INT A/VAL "2")*VAL "2")

```

It will now `PRINT` `1` for even and `0` for odd. Zero exits.

Here are older versions of the symbolic listing for reference purposes:

```
 1 INPUT A
 2 IF NOT A THEN STOP
 3 LET B=INT (INT A/2)
 4 PRINT A;":";NOT INT A-B*2
 5 RUN

```

Here is the old (v0.01) listing so that you may see the improvements that I've made as not only is this new listing smaller, but it's faster:

```
 1 INPUT A
 2 IF A<1 THEN STOP
 3 LET B=INT (INT A/2)
 4 LET M=1+INT A-B*2
 5 PRINT A;":";
 6 GOSUB M*10
 7 RUN
10 PRINT "TRUE"
11 RETURN
20 PRINT "FALSE"
21 RETURN

```

And here is v0.02 (using Sinclair sub strings):

```
 1 INPUT A
 2 IF NOT A THEN STOP
 3 LET B=INT (INT A/2)
 4 LET M=1+INT A-B*2
 5 LET C=4*(M=2)
 6 PRINT A;":";"TRUE FALSE"(M+C TO 5+C+(M=2))
 7 RUN

```
> 12 votes

# Answer
# brainfuck, 12 bytes

```
,++[>++]>++.

```

This requires an interpreter with a circular tape and cells that wrap around. The one on TIO has 65,536 8-bit cells and satisfies the requirements.

I/O is in bytes. Odd inputs map to **0x00** (falsy), even inputs to a non-zero byte (truthy).

Try it online!

### How it works

We start by reading a byte of input with `,` and adding **2** to its value with `++`. We'll see later why incrementing is necessary.

Next, we enter a loop that advances to the cell at the right, add **2** to it, and repeats the process unless this set the value of the cell to **0**.

Initially, all cells except for the input cell hold **0**. If the input is odd, adding **2** to it will never zero it out. However, after looping around the tape **127** times, the next iteration of the loop will set the cell to the right of the input cell to **128 × 2 = 0 (mod 256)**, causing the loop to end. `>++` repeats the loop body one more time, so next cell is also zeroed out and then printed with `.`.

On the other hand, if the input is **n** and **n** is even, the code before the loop sets the input cell to **n + 2**. After looping around the tape **(256 - (n - 2)) / 2 = (254 - n) / 2** times, the input cell will reach **0**, and the cell to its right will hold the value **(254 - n) / 2 × 2 = 254 - n**. After adding **2** with `>++`, `.` will print **256 - n = -n (mod 256)**, which is non-zero since **n** is non-zero.

Finally, note that the second case would print **258 - n = 2 - n (mod n)** if we didn't increment the input before the loop, since one more loop around the tape would be required to zero out the input cell. The program would thus fail for input **2**.
> 11 votes

# Answer
# Intel 8080 machine code, 1 byte

```
1F      RAR     ; rotate accumulator's least significant bit into Carry Flag

```

Input is in `A`, result is `CF=1` if odd, `CF=0` if even.

Here is a test program for the MITS Altair 8800 that will take the input number and display the result (odd or even) on the front panel lights. Just follow these programming instructions on the front panel switches:

```
Step    Switches 0-7    Control Switch  Instruction Comment
1                       RESET
2       00 111 110      DEPOSIT         MVI  A, 27  Load number to examine into A
3       00 011 011      DEPOSIT NEXT                Set value to test (27 in this case)
4       00 011 111      DEPOSIT NEXT    RAR         Rotate A's LSB into CF
5       11 110 101      DEPOSIT NEXT    PUSH PSW    Push Status Flags to stack
6       11 000 001      DEPOSIT NEXT    POP  B      Pop Status Flags to BC register
7       00 111 110      DEPOSIT NEXT    MVI  A, 1   CF is LSB (0x1) of Status Flags
8       00 000 001      DEPOSIT NEXT
9       10 100 001      DEPOSIT NEXT    ANA  C      Mask CF so is only result displayed
10      11 010 011      DEPOSIT NEXT    OUT  255    display contents of A on data panel
11      11 111 111      DEPOSIT NEXT
12      01 110 110      DEPOSIT NEXT    HLT         Halt CPU
13                      RESET                       Reset program counter to beginning
14                      RUN
15                      STOP
                                                    D0 light will be on if value is odd,
                                                    or off if even

```

If entered correctly, the program in RAM will look like: `0000 3e 1b 1f f5 c1 3e 01 a1 d3 ff 76`

To re-run with a another number:

```
Step    Switches 0-7    Control Switch      Comment
1                       RESET
2       00 000 001      EXAMINE             Select memory address containing value
3       00 000 010      DEPOSIT             Enter new value in binary (2 in this case)
4                       RESET
5                       RUN
6                       STOP

```

Try it online! Just follow the easy steps above!

**Output**

Input = `27`, light `D0` is ON indicating ODD result:

Input = `2`, light `D0` is OFF indicating EVEN result:
> 11 votes

# Answer
# 05AB1E, 1 byte

```
È

```

Fairly self-explantory. Returns `a % 2 == 0`

Try it online!
> 10 votes

# Answer
# Pyth, ~~3~~ 2 bytes

I did it. I golfed the ungolfable. For once, it's a non-trivial solution that managed to get that last byte!

```
!F

```

Truthy on even values (not including 0, but that's not positive so...).

Explanation:

```
!    Not
 FQQ Applied to the input (first Q) Q times

```

For example, `!!2 = !0 = 1`, and `!!!3 = !!0 = !1 = 0`

I'll keep my library of 3-byte solutions here below.

"There's another answer with multiple 3-byte solutions, but it's far from complete. Let's add a couple more:

```
@U2

```

Indexes into the list `[0,1]` modularly, giving truthy values on odd input.

```
}2P

```

Is 2 in the prime factorization of the input? (Truthy on even)

```
ti2

```

Is the GCD of 2 and the input 2? (Truthy on even)

```
gx1

```

does XOR-ing the input with 1 not decrease it? (Truthy on even)

```
q_F

```

Basically `Q == Q*-1^Q` where Q is the input, but done through a loop. (Truthy on even)

```
_FI

```

Same as above.

```
g^_

```

Translates to `Q <= -Q^Q` (Truthy on even)

Note that any of the above solutions involving `g` will work with `<` for flipped truthy-falsiness.)
> 10 votes

# Answer
# BitCycle, ~~19 17 16~~ 15 bytes

```
?ABv
 // <
!+\<

```

Try it online!

~~Argh, I feel like there's a 18 byte solution floating just out of reach :(~~ Haha! -2 bytes by using a `+` to redirect bits coming from different directions.

### Explanation:

```
?ABv   Feed unary input into the main loop
 /     Every loop, two bits will be removed from the input
 +\<   By the \ and /s each

```

```
       When we reach the point where there is either one or no bits of input left
 // <  If one, it will reflect off all three /\s and turn west at the +
!+\    And then output, otherwise the program ends since no more bits are moving

```
> 10 votes

# Answer
## Retina, 3 bytes

```
11

```

The trailing newline is significant. Takes input in unary. Outputs 1 for odd numbers, nothing for even numbers. Try it online!
> 9 votes

# Answer
# Brain-Flak, ~~22~~ 20 bytes

*Here is annother cool answer in Brain-Flak you should also check out*

```
(({})){({}[()]<>)}<>

```

Try it online!

## Explanation

To start we will make a copy of our input with `(({}))`.

The bottom copy will serve as a truthy value while the top one will be used for the actual processing. This is done because we need the input to be on the top and it is rather cumbersome (two extra bytes!) to put a 1 underneath the input.

Then we begin a loop `{({}[()]<>)}`. This is a simple modification on the standard countdown loop that switches stacks each time it decrements.

Since there are two stacks an even number will end up on the top of the stack it started on while an odd number will end on the opposite stack. The copied value will remain in place and thus will act as a marker of where we started.

Once we are done with the loop we have a `0` (originally the input) sitting on top of either a truthy (the copy of the input) or falsy (empty stack) value. We also have the opposite value on the other stack.

We need to get rid of the `0` which can be removed either by `{}` or `<>`. Both seem to work and give opposite results, however `{}` causes a falsy value for zero, when it should return truthy. This is because our "truthy" value is a copy of the input and zero is the only input that can be falsy.

This problem is resolved by ending the program with `<>` instead.

(Of course according to the specification I do not technically have to support zero but give two options I would prefer to support it)
> 8 votes

# Answer
# TIS-100, 39 bytes

Of course, this is, more precisely, a program for the T21 Basic Execution Node architecture, as emulated by the TIS-100 emulator.

I'll refer you to this answer for a fantastically in-depth explanation of the scoring for TIS-100 programs, as well as their structure.

```
@0
ADD UP
G:SUB 2
JGZ G
MOV ACC ANY

```

Explanation:

```
@0          # Indicates that this is node 0
ADD UP      # Gets input and adds it to ACC, the only addressable register in a T-21
G:          # Defines a label called "G"
SUB 2       # Subtracts 2 from ACC
JGZ G       # If ACC is greater than 0, jumps to G
MOV ACC ANY # Sends the value of ACC to the first available neighbor; in this case, output.
            # Implicitly jumps back to the first line

```

In pseudocode, it'd look something like:

```
while (true) {
    acc = getIntInput()
    do {
        acc -= 2
    } while (acc > 0)
    print(acc)
}

```

The T21 doesn't have boolean types or truthy/falsy values, so the program returns -1 for odd numbers and 0 for even numbers, unless the previous input was odd, in which case it returns -1 for even numbers and 0 for odd numbers - if that fact disturbs you, this is a full-program answer, so you can just restart your T21 between uses.
> 8 votes

# Answer
# C++, 25 bytes

```
template<int v>int o=v&1;

```

This defines a variable template (a function-like construct) with value equal to the bitwise operation `input&1`. `0` for even values, `1` for odd values. The value is calculated on compile-time.

Requires C++14.

Try it online!
> 8 votes

# Answer
## C#, 8 bytes

```
n=>n%2<1

```

Compiles to a `Func<int, bool>`.

Or if an anonymous function is disallowed, this method for 21 bytes:

```
bool p(int n)=>n%2<1;

```
> 7 votes

# Answer
# , 18 characters, 7 bytes

```
177407770236713353

```

Try it online!

7 doesn't have anything resembling a normal if statement, and has more than one idiomatic way to represent a boolean. As such, it's hard to know what counts as truthy and falsey, but this program uses `1` for odd and the null string for even (the truthy and falsey values for Perl, in which the 7 interpreter is written). (It's easy enough to change this; the odd output is specified before the first 7, the even output is specified between the first two 7s. It might potentially need an output format change to handle other types of output, though; I used the two shortest distinct outputs here.)

7 uses a compressed octal encoding in which three bytes of source represent eight bytes of program, so 18 characters of source are represented in 7 bytes on disk.

## Explanation

```
177407770236713353
 77  77     7       Separate the initial stack into six pieces (between the 7s)

        023         Output format string for "output integers; input one integer"
       7   6        Escape the format string, so that it's interpreted as is
             13     Suppress implicit looping
               3    Output the format string (produces input)
                5   Run the following code a number of times equal to the input:
   40                 Swap the top two stack elements, escaping the top one
                 3  Output the top stack element

```

Like many output formats, "output integers" undoes any number of levels of escaping before outputting; thus `40`, which combined make a swap-and-escape operation, can be used in place of `405`, a swap operation (which is a swap-and-escape followed by an unescape). If you were using an output format that isn't stable with respect to escaping, you'd need the full `405` there. (Incidentally, the reason why we needed to escape the format string originally is that if the first output contains unrepresentable characters, it automatically forces output format 7. Escaping it removes the unrepresentable characters and allows format 0 to be selected.)

Of the six initial stack elements, the topmost is the main program (and is consumed by the `13` that's the first thing to run); the second is the `023` that selects the output format and requests input, and is consumed by that operation; the third is consumed as a side effect of the `3` operation (it's used to discard stack elements in addition to producing output); the fourth, `40`, is the body of the loop (and consumed by the `5` that executes the loop); and the fifth and sixth are swapped a number of times equal to the input (thus end up in their original positions if the input is even, or in each others' positions if the input is odd).

You could golf off a character by changing the leading `177` to `17` (and relying on an implicit empty sixth stack element), but that would change the parity of the outputs to a less idiomatic method than odd-is-true, and it doesn't save a whole byte (the source is still seven bytes long). As such, I decided to use the more natural form of output, as it doesn't score any worse.
> 7 votes

# Answer
# Pyth, 3

I was expecting pyth to have a 1 or 2 byte builtin for this. Instead here are the best solutions I could find:

```
%Q2

```

or

```
.&1

```

or

```
e.B

```
> 7 votes

# Answer
# Bash + bc, 21 14 11 9 bytes

```
bc<<<$1%2

```

Reads command-line input, expands the value into the string with the mod operation, and pipes the string to bc for calculation. Outputs 1 for odd, 0 for even.

Test cases:

```
(Input):(Output)
1:1
2:0
16384:0
99999999:1

```

Edit: saved 7 bytes thanks to @ais523
Edit 2: saved another 3 bytes thanks to @Dennis
Edit 3: saved another two thanks to @Dennis
> 7 votes

# Answer
# Jelly, 1 byte

Try it online!

Just another builtin.

For people who don't know Jelly: it has quite a bit of ability to infer missing bits of code, thus there isn't much syntactic difference between a snippet, a function, and a full program; the interpreter will automatically add code to input appropriate arguments and output the result. That's pretty handy when dealing with PPCG rules, which allow functions and programs but disallow snippets. In the TIO link, I'm treating this as a function and running it on each integer from 1 to 20 inclusive, but it works as a full program too.

# Jelly, 2 bytes

```
&1

```

Try it online!

It's pretty short without the builtin, too. (This is bitwise-AND with 1.)
> 6 votes

# Answer
# Pure Bash, 8

* 3 bytes saved thanks to @Dennis

```
(($1%2))

```

Input given as a command-line parameter to this function `f`. Output returned as a shell return value - display with `echo $?`
> 6 votes

# Answer
## Alice, 7 bytes

```
1\@
oAi

```

Try it online!

Prints `0` for even inputs and `1` for odd inputs.

### Explanation

This is structurally similar to my addition program, but the flipped mirror subtly changes the control flow:

```
1    Push 1.
\    Reflect northeast. Switch to Ordinal.
     Bounce off the boundary, move southeast.
i    Read all input as a string.
     Bounce off the corner, move back northwest.
\    Reflect south. Switch to Cardinal.
A    Implicitly convert input string to integer. Compute bitwise AND with 1.
     Wrap around to the first line.
\    Reflect northwes. Switch to Ordinal.
     Bounce off the boundary, move southwest.
o    Implicitly convert result to string and print it.
     Bounce off the corner, move back northeast.
\    Reflect east. Switch to Cardinal.
@    Terminate the program.

```
> 6 votes

# Answer
## Labyrinth, 5 bytes

```
?_2%!

```

Prints `0` for even and `1` for odd inputs.

Try it online!

```
?   Read input.
_2  Push 2.
%   Modulo.
!   Print.

```

Now the instruction pointer hits a dead end and turns around. Upon attempting the `%` on an empty stack, the program exits due to division by zero.

## alternatively, also 5 bytes

```
?#&!@

```

Try it online!

```
?   Read input.
#   Push stack depth (1).
&   Bitwise AND (extract least-significant bit).
!   Print.
@   Terminate.

```
> 5 votes

# Answer
## Hexagony, 7 bytes

```
?{2\%'!

```

Prints `0` for even numbers (falsy) and `1` for odd numbers (truthy).

Try it online!

### Explanation

Here is the folded code:

```
 ? {
2 \ %
 ' !

```

I believe this is optimal although not unique. As usual I've run a brute force search (not an exhaustive one, but the characters I've excluded are very unlikely to be useful for this program). It did find a whole bunch of other solutions, which I haven't investigated in detail yet:

```
^?"2^%!
^?"2}%!
{?"2^%!
{?"2}%!
2^?\%"!
2}?\%"!
\{?2%'!
2^?")%!
2^?"1%!
2^?"2%!
2^?=^%!
2{?"}%!
2{?'=%!
2{?={%!
2}?")%!
2}?"1%!
2}?"2%!
2}?=^%!
|"?^2%!
)>"?}!%
\}2?%"!
2^=?^%!
2{'?^%!
2{=?{%!
2}=?^%!

```

As for the solution I've picked above:

```
?   Read input.
{   Move to the left memory edge.
    The IP wraps around to the left corner.
2   Set the memory edge to 2.
\   Deflect the IP southwest.
'   Move to the memory edge that points at the input and at the 2.
    The IP wraps around to the right corner.
%   Take the input modulo 2.
!   Print the result.
    The IP wraps to the top right corner.
{   Move to the input edge, which points at two empty edges.
%   Attempt to take the modulo of those, which terminates the program
    due to the attempted division by zero.

```

I did look at the next program the above list, which is quite fun because it loops through the first two lines 6 times, filling an entire hexagonal ring with `2`s before wrapping back around to the first and taking the modulo. At that point it actually uses the *second* `2` for the computation. I'm sure there are some gems in the others as well, but I don't think I'll have the time to go through them in detail.
> 5 votes

# Answer
# Excel, 10 bytes

```
=MOD(A1,2)

```

Or:

```
=ISODD(A1)

```

For output of:
> 5 votes

# Answer
# Cubix, 6 bytes

```
OI2%/@

```

This outputs `1` for odd numbers, and `0` for even. Try it here!

# Explanation

First, the cube form.

```
  O
I 2 % /
  @

```

The following instructions are executed:

```
I2%O2@ # Explanation
I      # Take input
 2%    #   Modulo 2
   O   #   Output
    2  # Push 2 to the stack
     @ # End the program

```
> 5 votes

# Answer
# JSFuck, ~~9685~~ ~~9384~~ 6420 bytes

JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.

```
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]])+[])[!+[]+!+[]]+(!![]+[])[+[]]+(+(+!+[]+[+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+[+!+[]])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]+!+[]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+(!![]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(+(!+[]+!+[]+[+!+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+!+[]+[+!+[]])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]])()(([]+[])[([![]]+[][[]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]]()[+[]])[+[]]+[!+[]+!+[]])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]]

```

Outputs 1 for odd and 0 for even.

### Try it online!

```
alert([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]])+[])[!+[]+!+[]]+(!![]+[])[+[]]+(+(+!+[]+[+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+[+!+[]])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]+!+[]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+(!![]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(+(!+[]+!+[]+[+!+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+!+[]+[+!+[]])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]])()(([]+[])[([![]]+[][[]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]]()[+[]])[+[]]+[!+[]+!+[]])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]](prompt()))
```
> 5 votes

# Answer
# Haskell, 3 bytes:

```
odd

```

It's built-in. Works as expected. There is also `even` but of course that's one byte longer.
> 5 votes

# Answer
# Swift Compiler, chained types, ~~57~~  ~~43~~ 39 bytes

Way shorter than the other one but way less fun.

```
struct A{enum T{typealias T=A}}
_=A.T()

```

SwiftFiddle link

Input is the number of T's on the last line: 1 is `A.T`, 2 is `A.T.T`, and so on. The program only compiles if there is an even number of T's.

## Swift Compiler, nested types/tag system, 565 bytes

```
protocol P{associatedtype T:P
associatedtype A:P
associatedtype B:P
associatedtype C:P}
protocol Q{}
enum H:P,Q{typealias T=H
typealias A=H
typealias B=H
typealias C=H}
enum E:P,Q{typealias T=H
typealias A=a<E>
typealias B=b<E>
typealias C=c<E>}
struct a<T:P>:P{typealias A=a<T.A>
typealias B=a<T.B>
typealias C=a<T.C>}
extension a:Q where T.T.C.B:Q{}
typealias Z<T:P>=a<T>
enum b<T:P>:P{typealias A=b<T.A>
typealias B=b<T.B>
typealias C=b<T.C>}
extension b:Q where T.T.A:Q{}
enum c<T:P>:P{typealias A=c<T.A>
typealias B=c<T.B>
typealias C=c<T.C>}
let x:Q=Z<a<E>>()

```

SwiftFiddle link

The input is the number of a's on the last line, so `Z<a<E>>` is 1, `Z<a<a<E>>>` is 2, and so on. The program only compiles if there is an even number of a's.

Prior work: this Swift forums post in which Slava Pestov embedded a tag system at the type level.

If the reverse condition is allowed -- truthy for odd and falsy for even -- `Z` can be removed, for **540 bytes**.
> 5 votes

# Answer
## Batch, 16 bytes

```
@cmd/cset/a%1%%2

```

Outputs 1 for odd, 0 for even. Alternative 16-byte version also works on negative numbers:

```
@cmd/cset/a"%1&1

```

17 bytes to output 1 for even, 0 for odd:

```
@cmd/cset/a"~%1&1

```
> 4 votes

# Answer
# Octave, 12 bytes

```
@(x)mod(x,2)

```

Takes `x` modulus `2`. Returns `0` for even numbers and `1` for odd numbers. These evaluates to false and true respectively in Octave. This works in MATLAB too.
> 4 votes

# Answer
## QBasic 4.5, ~~16~~ 15 bytes

```
INPUT a
?1AND a

```

*One byte saved by @DLosc!*

This shows a 1 for odd numbers and a 0 for even.
> 4 votes

# Answer
## R, ~~12~~ ~~10~~ 9 bytes

```
scan()%%2

```

Outuputs `1` for `TRUE` or `0` for `FALSE` when input in even or odd (respectively)

`0` is supported.

-*2* bytes thanks to @plannapus
-*1* byte thanks to @user2390246
> 4 votes

# Answer
# Brain-Flak, ~~26~~ 22 bytes

```
({}(())){({}[()]<>)}{}

```

Even: `<nothing>`
Odd: `1`
Try it online!

```
({}            # Pick up the input
   (())        # Push 1
        )      # put the input back down

{          }   # While not 0
 ({}[()]  )    # Subtract 1 and...
        <>     # move to the other stack (bringing the input)
            {} # Pop the input (now 0)

```
> 4 votes

# Answer
## Scratch, 4 blocks + 1 byte

Python equivalent:

```
i = input()
print(i % 2)

```

Returns 0 for even and 1 for odd.
> 4 votes

# Answer
# Neim, 1 byte

Try it online!

Explanation:

```
ᛄ: modulo 2 (implicit input and output)

```
> 4 votes

# Answer
# Flurry `-nii`, ~~14~~ ~~12~~ 10 bytes

```
{}{{}[]}{}

```

Try it online!

Found a better zero-one alternating function: `\x. x 0`, and realized that the zero can be fetched from the stack height. Also, changing the last `{}` to `[]` gives 0 for even and 1 for odd, essentially implementing `n%2`.

```
(\x. x 0) 1 = 1 0 = 0^1 = 0
(\x. x 0) 0 = 0 0 = 0^0 = 1

```

---

# Flurry `-nii`, ~~14~~ 12 bytes

```
{}{{}(){}}{}

```

Try it online!

Easier one found by Esolanging Fruit. Basically applies the function "return 1 if the input is 0, return 0 if the input is 1" n times to 1.

-2 bytes because the inner I `{{}}` could be fetched from the empty stack as `{}`.

```
//     {} {...}  {}
main = n  swap01 1
//       {   {} () {} }
swap01 = \x. x  K  I
// swap01 0 = 0 K I = I = 1    (K applied zero times to I)
// swap01 1 = 1 K I = K I = 0  (K applied once to I)

```

---

# Flurry `-nii`, 24 bytes

```
{}{{}[<><<>()>]}{}[<>()]

```

Try it online!

### How it works

Uses the "succ chain" trick: the expression `succ succ ... succ` (`succ` repeated `k` times) with a Church numeral argument `n` gives a polynomial on `n`:

```
succ n = n + 1
succ succ n = n^2 + n
succ succ succ n = n^2 + n + 1
succ succ succ succ n = n^3 + n^2 + n
...

```

In general,

* `succ` repeated `2k` times gives `n^(k+1) + n^k + ... + n`
* `succ` repeated `2k+1` times gives `n^(k+1) + n^k + ... + n + 1`

Alternatively, even-th repetition multiplies by `n` and odd-th repetition adds 1.

Such an alternating behavior can be used to distinguish between even and odd numbers. If you repeat `succ` `n` times to 0, it cycles between "add 1" and "times 0", effectively giving 0 and 1 for even and odd respectively. But we can't simply concatenate `succ` `n` times; we need to apply `succ` `n` times to `I`.

```
X = {{}[<><<>()>]}  \x. x succ
                    apply succ to given function
main = {}X{}[<>()]  n X I 0
                    apply X n times to I (giving length-n chain of succ)
                    then call it with 0

n = 1 -> main = succ 0 = 1
n = 2 -> main = succ succ 0 = 0
n = 3 -> main = succ succ succ 0 = 1
...

```
> 4 votes

# Answer
# Vyxal, 1 byte

Try it Online!

0 for even, 1 for odd.

Alternatively,

Try it Online!

1 for even, 0 for odd.
> 4 votes

# Answer
# KonamiCode, ~~111~~ 109 bytes

`>>>>(^^)v(>)>(^)v(>)L(>)>(^)v((>))>(^^)S(^)A(^^)v(^)A(^>)L(^^)v(>)B(^^^)L(^^^)L(^>)>(>)S((^))>(^)B(>)>(^^)<<<`

## Explanation

KonamiCode lacks a modulo function, so I'm detecting if a number is odd or even using the following algorithm:

```
While a counter is less than the number to check:
    If x is 0:
        Set x to 1
    Else:
        Set x to 0
Output the number

```

This has the effect of having x be 0 if the input is even, and 1 if it is odd.

Annotated code: (I'm using x to refer to the x value in the above example)

```
>>> [Raw input, to get the number to check]
[The next few instructions set up the values in memory]
>(^^) [Sets up "x"]
v(>)
>(^) [Sets up the counter]
v(>)
L(>)
  [We are now inside a loop.]
  >(^)
  v((>)) [Increase the counter]
  >(^^) [Go to x's position in memory (address 2)]
  S(^) [Set the comparison buffer to 1]
  A(^^) [If the comparion buffer equals the current memory value, go to L(^^).
  This will happen if x is 1.]
  [This point is only reached if x is not 1]
  v(^) [Sets x to 1]
  A(^>) [If x is 1 jump to L(^>)

  L(^^) [If x was 1 we jumped to here]
  v(>) [Sets x to 0]
  B(^^^) [If x is not 1 jump to L(^^^)

  L(^^^)
  L(^>)
  [Finally, we reset everything and loop again]
  >(>)
  S((^))
  >(^)
B(>)
[Print the result and finish.]
>(^^)
<<<

```
> 4 votes

# Answer
# Python, 12 bytes

```
lambda x:x%2

```

use with

```
g = lambda x:x%2
g(a)

```

where a is the input number. Returns 1 for Odd, and 0 for Even.
> 3 votes

# Answer
# Perl 5, 6 bytes

5 bytes of code + `-p` flag.

```
$_%=2

```

Try it online!
> 3 votes

# Answer
# Ruby, 10 bytes

```
->x{x&1<1}

```

True for even, false for odd.
> 3 votes

# Answer
# Clojure, 4 bytes

```
odd?

```

A function which checks if its argument is odd. Example usage: `(odd? 3)`. Clojure does also have `even?` function.
> 3 votes

# Answer
# Ohm, 2 bytes

```
è

```

Explanation:

```
è: (pop()%2)==1
Ohm also has implict input and output

```
> 3 votes

# Answer
# PHP, 14 bytes

```
<?=$argv[1]%2;

```

Try it online!

Outputs `1` for odd, `0` for even.
> 3 votes

# Answer
# Julia 0.5, 5 bytes

```
isodd

```

Try it online!
> 3 votes

# Answer
# Sesos, 2 bytes

**SASM**

```
set numin
get
jmp, sub 2

```

**SBIN**

```
00000000: 1228                                              .(

```

Output is via exit code, zero for *even* and non-zero for *odd*. Odd inputs may take a *long* time.

Try it online!

### How it works

This is a bit cheaty, but it complies with our rules.

The program reads a decimal integer from STDIN and keeps subtracting **2** until it reaches **0**. For even inputs, this finishes in linear time and does nothing, successfully.

Programs that do not contain the `set mask` directive use arbitrary precision integers, so odd inputs will slowly continue to allocate memory. Once the available memory is exhausted, the program will get killed, resulting in a non-zero exit code. Don't expect this to happen anytime soon...

## Alternate version, 3 bytes

### SASM

```
set numin
get
jmp, sub 2

```

### SBIN

```
00000000: 124601                                            .F.

```

Output is via exit code, zero for *even* and non-zero for *odd*. Stray output to STDOUT should be ignored.

Try it online!

### How it works

Marginally less cheaty. The program works as before, but also prints the tape cell as a character in each iteration. This will exit with an error once the cell becomes negative.
> 3 votes

# Answer
# PowerShell, 9 bytes

```
"$args"%2

```

Try it online!

Ho-hum. Takes input `$args` and stringifies it, because there can be an implicit cast from string to int, but not from array to int. Then runs that through modulo `2`. Outputs `0` (a falsey value) for even and `1` (a truthy value) for odd.
> 3 votes

# Answer
# TI-Basic-83, 4 bytes

```
fPart(.5Ans

```

Gets the partial fraction part of `1/2` multipled by `Ans`, returns 0 if even, anything else if odd.
> 3 votes

# Answer
# TacO, 29 bytes

```
   2i i
  i -+*2
@+%#?v
    1

```

Outputs `1\n` if even, or just `\n` if odd.

This takes all multiples of 2 from `2` to `2n`, removes all the ones in which `n - i ~= 0` and sets the rest to `1`, then sums that list.

Try it online!
> 3 votes

# Answer
# PHP, 12 bytes

```
echo$argn&1;

```

Run like this:

```
echo 123 | php -R 'echo$argn&1;';echo

```
* Odd: 1
* Even: 0
> 3 votes

# Answer
## Rail, 29 bytes

```
$'main'
oi
r e
|  >{main}
\2-

```

Try it online!

### Explanation

Every time I try to golf something in Rail, I remember how incredibly tricky it is, because of how strict the track placement rules are (especially for junctions). I think this is the first time, that I actually used recursion (or any method calls at all).

Rail programs start from the `$`, going southeast. `i` reads a character from STDIN. `e` checks for EOF. `>` is a three-way junction. It pops the result from the EOF check. If we haven't reached EOF yet, the train takes the left-turn. `{main}` is a recusive call to the `main` routine, which really just means that we'll start over from the beginning.

Once we've reached EOF, the train will take the right-turn at the junction. The `-`, `\` and `|` on the remainder of the track are necessary to make the train take a couple of turns. `2` pushes `2`, `r` computes the last digit modulo `2` (`r` for "remainder") and `o` outputs it. Technically, we'd have to terminate the track with `#`, but I ran out of space and the program exits either way, sadly, crashing the train.

This version of the trolley problem (do I save the trolley or do I save the bytes) seems to be more easily resolved than the classical one...

## alternatively, also 29 bytes

```
$'main'
 |/i-
 |   >2ro
 \-e/

```

Try it online!

This one uses a physical loop in the tracks. The basic idea is the same: the track initially leads to the EOF-check `e`, after which we reach the 3-way junciton. As long as there is input left to reach, we read one character with `i` and loop back into the previous track. Once we reach EOF we compute and print the parity with `2ro`.

Obviously, we still can't afford the extra byte to prevent the train from derailing.
> 3 votes

# Answer
# Taxi, 797 bytes

```
Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:w 1 l 1 r.Pickup a passenger going to Divide and Conquer.Go to Starchild Numerology:e 1 l 1 l 1 l 2 l.2 is waiting at Starchild Numerology.Pickup a passenger going to Divide and Conquer.Go to Divide and Conquer:w 1 r 3 r 1 r 2 r 1 r.Pickup a passenger going to Cyclone.Go to Cyclone:e 1 l 1 l 2 l.Pickup a passenger going to Equal's Corner.Pickup a passenger going to Trunkers.Go to Trunkers:s 1 l.Pickup a passenger going to Equal's Corner.Go to Equal's Corner:w 1 l.Switch to plan "O"if no one is waiting.1 is waiting at Writer's Depot.Switch to plan "E".[O]0 is waiting at Writer's Depot.[E]Go to Writer's Depot:n 1 l 1 r.Pickup a passenger going to Post Office.Go to Post Office:n 1 r 2 r 1 l.

```

Try it online!

Ungolfed:

```
Go to Post Office: west 1 left, 1 right, 1 left.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery: west 1 left, 1 right.
Pickup a passenger going to Divide and Conquer.
Go to Starchild Numerology: east 1 left, 1 left, 1 left, 2 left.
2 is waiting at Starchild Numerology.
Pickup a passenger going to Divide and Conquer.
Go to Divide and Conquer: west 1 right, 3 right, 1 right, 2 right, 1 right.
Pickup a passenger going to Cyclone.
Go to Cyclone: east 1 left, 1 left, 2 left.
Pickup a passenger going to Equal's Corner.
Pickup a passenger going to Trunkers.
Go to Trunkers: south 1 left.
Pickup a passenger going to Equal's Corner.
Go to Equal's Corner: west 1 left.
Switch to plan "Odd" if no one is waiting.
1 is waiting at Writer's Depot.
Switch to plan "Even".
[Odd]
0 is waiting at Writer's Depot.
[Even]
Go to Writer's Depot: north 1 left 1 right.
Pickup a passenger going to Post Office.
Go to Post Office: north 1 right 2 right 1 left.

```
> 3 votes

# Answer
# K (oK), 2 bytes

```
2!

```

Try it online!
> 3 votes

# Answer
## Funciton, 68 bytes

Byte count assumes UTF-16 encoding with BOM.

```
╓─╖
║p║
╙┬╜┌┐
 ├─┤├
╔╧╗└┘
║1║
╚═╝

```

Try it online!

This defines a function `p` which takes a single integer and returns `0` for even and `1` for odd numbers.

### Explanation

```
╓─╖
║p║
╙┬╜

```

This is the function declaration header. The line leaving the box will emit the input of the function when called.

```
╔╧╗
║1║
╚═╝

```

This is a literal. The line leaving the box will emit a `1`.

```
 ├─

```

This T-junction computes the bitwise NAND of its inputs, and emits it to the right.

```
   ┌┐
   ┤├
   └┘

```

Finally, we compute the bitwise NOT, by splitting the value on first T-junction and computing the bitwise NAND with itself on the second T-junction.

The loose end on the right is used as the function's output value. Hence, the overall function computes:

```
p(x) = NOT(NAND(x, 1)) = AND(x, 1)

```
> 3 votes

# Answer
# Lua, 20 bytes

```
print(io.read()%2<1)

```

This returns true if **STDIN mod 2** is 0 and returns false if it isn't. You can also remove the **\<0** to get the opposite results.
> 3 votes

# Answer
# OIL, 39 bytes

```
5
0
9
0
10
0
1
16
9
9
0
10
0
1
17
2
4
4

```

## Explanation:

`5` `0` reads the input into line 0. `9` `0` decrements line 0 (using the fact that the input must be *positive* (i.e. \>0)).

`10` `0` `1` compares line 0 to line 1 (which contains a `0`). If they're identical, that means the number must have been odd, jump to cell 16.

`9` `0` decrements line 0 again. `10` `0` `1` does the same comparison again, except this time equality means the number was even, jump to cell 17. Otherwise go on with the decrementation process (jump to line 2).

Line 16 and 17 both contain a `4` (print), meaning if we jumped to line 16, `4` `4` will print what's in line 4 (`10`). If we jumped to line 17 instead, `4` (`0`) will print 0, the value in line 0.
> 3 votes

# Answer
# Symbolic Python, 6 bytes

```
_&=_/_

```

Try it online!

Input and output happens through the variable `_` \- its initial value is the input, and its final value is the output.

The code works by returning the least significant bit, performing `_ &= 1`. However, as `1` is obviously not allowed in Symbolic Python, `_/_` is used, which is of course `1` for all inputs.
> 3 votes

# Answer
# Regex (ECMAScript), 7 bytes

```
^(xx)*$

```

Try it online!

The input is in unary, as the length of a string of `x`s. It matches even numbers and returns "no match" for odd numbers.

This works in all regex flavors, even formal regular expressions, which lack some ECMAScript regex features (backreferences and lookaheads).

There is no shorter (6 bytes or less) unary ECMAScript regex function (with nonnegative integer input and match/no-match output) that requires the `(`, `)`, `*`, or `+` symbols.
> 3 votes

# Answer
# Turing Machine Code, 99 bytes

```
0 * * r 0
0 _ _ l 1
1 0 0 * A
1 2 2 * A
1 4 4 * A
1 6 6 * A
1 8 8 * A
A * * * halt-e
1 * * * halt-o

```

Outputs via the halt state, terminating in state `halt-e` for even or `halt-o` for odd.

Try it online.
> 3 votes

# Answer
# Re:direction, 7 bytes

```
♦♦
▼►
◄

```

Outputs 1 if odd, and 0 if even. Basically works by alternating between the left and right side until a  is found ( is at the end of the input) and then outputs depending on which side it is on.

Try it online!
> 3 votes

# Answer
# Shakespeare Programming Language, 137 bytes

Try it online!

```
#.Ajax,.Puck,.Act I:.Scene I:.[Enter Ajax and Puck]Ajax:Listen tothy.You is the remainder of the quotient betweenyou a big cat.Open heart

```

Fairly simple, just outputs the input mod 2. Maybe improvable.
> 3 votes

# Answer
# Rust, 148 bytes

```
use std::io;fn main(){let mut d=String::new();io::stdin().read_line(&mut
 Rd);d=d.trim().to_string();let b=d.parse::<i32>().unwrap()%2;print!("{}",b)}

```

I'm really bad with rust, so this probably isn't very optimal, but I didn't see any other rust answers.

Try it online!
> 3 votes

# Answer
# Arn, 2 bytes

```
%2

```

Try it!

Returns `0` for even, `1` for odd. If you want the opposite,

```
!%2

```

would work.
> 3 votes

# Answer
# HP 48 User REPL, 15 bytes

```
« 1 + 2 MOD
»

```

French quote marks mark the var as a program

'1 +' - adds one to the number on the stack (input)

'2 Mod'- returns 0 when odd, 1 when even

1 is a truth in RPL and 0 is false, so we have to shift it up once to make it valid.

On the calculator this is 26 bytes despite the source being 15 including nonessential formatting.
> 3 votes

# Answer
# dc, 4 bytes

```
?2%p

```

Try it online!

Uses `1` for odd and `0` for even.

## Explanation

This is just straightforward modulo.

```
?    push input onto stack
2    push a 2 onto stack
%    take modulo of input and 2
p    print

```
> 3 votes

# Answer
# jq, 5 characters

```
.%2<1

```

Sample run:

```
bash-4.3$ jq '.%2<1' <<< 16384
true

```

On-line test:
> 2 votes

# Answer
# Haskell, 8 bytes

```
(`mod`2)

```

1 for odd and 0 for even Test cases:

```
>(`mod`2)1
1
>(`mod`2)2
0
>(`mod`2)999999
1

```

## Alternative with True/False output, 13 bytes

```
(==0).(`mod`2)

```

Test cases with repl usage:

```
>((<1).(`mod`2))1
False
>((<1).(`mod`2))2
True
>((<1).(`mod`2))16438
True
>((<1).(`mod`2))999999
False

```
> 2 votes

# Answer
# Python 2 REPL, 9 bytes

```
input()%2

```

### Sample run:

```
>>>input()%2
42
0

```

Outputs 0 for even and 1 for odd

Try it online!
> 2 votes

# Answer
# GNU sed, 7 bytes

This is also a regex only solution. Input in unary is allowed for sed, based on this meta consensus. No truthy / falsy values actually exist in sed, as there are no data types.

**Input as unary:** 7 bytes. Output is 0 for odd numbers, and nothing for even ones.

```
s:00::g     # input consists of only zeros (4 -> 0000). Two zeros are deleted as
            #many times as possible. Remaining pattern space is printed implicitly.

```

**Try it online!**

**Input as decimal:** 12 bytes. Output is 1 for odd numbers, and something other than 1 for even.

```
/[13579]$/c1     # if last char is 1, 3, 5, 7 or 9, then change pattern space to 1.
                 # Otherwise, do nothing. Implicit printing done at the end.

```

**Try it online!**
> 2 votes

# Answer
# Groovy, 7 bytes

```
{!it%2}

```

Answer too short for posting.
> 2 votes

# Answer
# SQLite, 10 bytes

```
SELECT x%2

```

Try it online!
> 2 votes

# Answer
## Jelly, 2 bytes

Here's an alternate approach to this Jelly answer by ais523

```
BṪ

B   convert the input to binary
 Ṫ  and return its last character: 0 for even, 1 for odd.

```

Try it online!

Also at 2 bytes, the classical Modulo 2:

```
%2

```

Try it online!

which also returns 0/1 for even/odd resp.
> 2 votes

# Answer
# Fortran 95,  ~~31~~  28 bytes

*Thanks to @georgewatson for saving three bytes!*

```
function h(i)
h=mod(i,2)
end

```

Returns 0 if even, 1 if odd.

Try it online!
> 2 votes

# Answer
# Forth, 11 bytes

```
: f 2 mod ;

```

**Try it online**

Output is `0` if even, `1` if odd.
> 2 votes

# Answer
# ZX Spectrum BASIC, ~~35~~ 31 characters

*Thanks to @Leo for removing 4 characters!*

*I don't know how to obtain the true (tokenized) program size, so the indicated score is in characters*

```
1 INPUT a
2 PRINT a/2-INT(a/2)

```

Output is `0.5` (which is truthy) for odd input, and `0` (which is falsy) for even input.

This was tested on the Windows SpecBAS interpreter.
> 2 votes

# Answer
# Perl 6, 4 bytes

```
*%%2

```

Try it

This is a WhateverCode lambda closure that takes one positional argument.

## Expanded:

```
*   # the parameter   (turns the expression into a WhateverCode)
%%  # is divisible by
2   # two

```
> 2 votes

# Answer
# Wise, 4 bytes

```
:><^

```

Try it Online! (Takes input through command line arguments for now)

Prints `1` for odd, `0` for even.

```
        Implicit input
:       Duplicate
 ><     Bitshift right, then left, which changes the least significant bit to 0
   ^    Xors with original
        Implicit output

```

A number is odd if the least significant bit is `1`. By xoring the input and the input with the least significant bit as 0, we get 1 on odd numbers (`0 != 1`), and 0 on even (`0 == 0`)
> 2 votes

# Answer
# BitCycle, 22 bytes

This program takes input on the command-line in unary; it outputs `1` for odd, nothing for even. You can also specify the `-u` flag and give input in decimal, in which case the output is `1` for odd, `0` for even.

```
?v
v<  <
A\\B^
>/\
  !

```

### Explanation

Here's a slightly ungolfed version in action (the same logic with extra space added for clarity):

The input bits come in at the source `?` and are routed into the `A` collector. Once the whole input is in there, bits are emitted one at a time to the right. The two splitters `\\` send the first two bits downward, while the remainder go into the `B` collector. (Splitters deactivate after the first time a bit hits them, so the second bit passes through the deactivated first splitter and is reflected by the second one.)

The second bit goes down, is reflected rightward by `\`, and goes off the playfield. Meanwhile, the first bit is reflected leftward by `/` and immediately sent rightward again by `>`. It passes through the two deactivated splitters and goes off the playfield. Finally, if there are any bits still in the `B` collector, they are now cycled around back to `A`. When the collectors come open, the splitters return to their original state, and the loop continues until there are less than two bits left.

If the number was even, there will be no bits left, in which case the program terminates without output. If the number was odd, there is a single bit left in `A`. The splitters `\` and `/` send it down and left to the `>`, which sends it to the right. It goes back through the deactivated `/` and hits the bottom-right `\`. The latter has not been deactivated this time because there wasn't a second bit. So it reflects the single bit downward into the sink `!`, which outputs it.
> 2 votes

# Answer
# Campfire, 8 bytes

Prints `1` for odd input or `0` for even input, then exits with an error.

```
&2&2%.%.

```

Campfire is an esoteric programming language I've created a couple of months ago. While it has a builtin for computing remainders, its unique flow of instructions makes even this simple challenge not so trivial (even if in this case the source turns out to be quite symmetric and nice).

In Campfire, after executing each instruction, the instruction pointer jumps to just after the next occurrence of the instruction just executed (wrapping between the end and the start of the code). Moreover, if the value on the top of the main stack is not 0, the instruction pointer is turned around before jumping (when backwards, it jumps to just before the previous occurrence of the executed instruction).

Here's an explanation of the execution of this program. `*` marks the instruction executed at each step, and `<`,`>`, or `?` marks the spot where the instruction pointer will jump to, along with its direction.

```
&2&2%.%.
* <          & takes a number from input and pushes it to the stack.
             Since we're dealing only with strictly positive numbers,
             we will always switch direction.
 * >         Push 2 to the stack (then switch direction)
    * ?      Compute remainder. If the result is 1 we will switch direction,
             if it's 0 we won't.
 #First alternative:
&2&2%.%.
     * <     Output the result, the stack is now empty, and an empty stack
             has impicit 0s on it, so we won't switch direction.
      *      Try to compute remainder, but the stack is composed only by
             implicit 0s, so this will exit the program with an error.
 #Second alternative:
&2&2%.%.
     > *     We execute the other output instruction, result is the same.
      *      Again, we end by computing 0%0.

```
> 2 votes

# Answer
# TI-Basic, 4 bytes

```
fPart(Ans/2

```

Other solutions:

```
remainder(Ans,2         5 bytes - returns 0 even 1 odd

```

Returns 0 for even numbers and 1/2 for odd numbers. These values evaluate to false and true respectively in TI-Basic.
> 2 votes

# Answer
# Clojure, 15 bytes

```
#(= 0(rem % 2))

```

Ignoring the obvious built-ins, this is probably as short as it gets.

Checks if the argument divided by 2 equals 0. Nothing fancy. Returns true for even numbers, false for odd.

Beaten by brainfuck!
> 2 votes

# Answer
# C, 11 bytes

```
f(n){n&=1;}

```

Because, why not. Returns false (0) for even, true (1) for odd.

Works with gcc on linux/x86.
> 2 votes

# Answer
# J-uby, 6 bytes

```
:even?

```

In J-uby, Ruby's symbols are callable. `Fixnum#even?` in Ruby (predictably) returns whether a number is even or not. It can be called like so:

```
f = :even?
f.(2) #=> true
f.(3) #=> false

```
> 2 votes

# Answer
# Scala, 14 Bytes

```
(x:Int)=>x%2<1

```
> 2 votes

# Answer
# Vim Macro 54 Bytes

```
^vehxiF^[ve"nyo1234567890^MFTFTFTFTFT^[k@njvyo^[pi^[k$vggx

```

This Vim Macro works on any file that contains just an integer. During the cleanup process, it removes all the code above itself. This can probably be better implemented where it cleans up only the code it wrote but that would require more bytes.

The `^[` is escape (return to normal mode) and the `^M` is the enter key.

What this basically does is it removes everything but the last digit of the number, prepends `F` to it, saves that into register `n` so now register `n` holds `F<your number>`. Then, it creates two new lines. One containing `1234567890` and the other line containing `FTFTFTFTFT`. Once it creates the second line, the cursor moves up, executes the `n` macro, thus finding backwards the first occurrence of `<your number>`, going down one line to the second line, yanking the corresponding true or false character from it, creating a new line, pasting that character, and then deleting everything it just did.

Vim Macros present a really interesting challenge and require you to think in a different way than what you're used to. It was super cool to work on this.
> 2 votes

# Answer
# PHP, 14 bytes

```
<?=$argv[1]&1;

```

When I test for odd or even, I only look at the first bit and not `%` the whole integer.
> 2 votes

# Answer
# x86\_64 Linux machine language, 5 bytes

```
0:       97                      xchg   %edi,%eax
1:       83 e0 01                and    $0x1,%eax
4:       c3                      retq

```

To try it, compile and run the following C program

```
#include<stdio.h>
const char f[]="\x97\x83\xe0\1\xc3";
int main(){
  for( int i = 0; i < 10; i++ ) {
    printf("%d %d\n", i, ((int(*)(int))f)(i) );
  }
}

```

Try it online!

EDIT: Fixed TIO link.
> 2 votes

# Answer
# Aceto, 6 bytes.

```
%2
rip

```

`ri` reads a string and casts it to an integer, `2%` does modulo 2, and `p` prints. 0 stands for even and 1 for odd in the printed result.
> 2 votes

# Answer
# Klein, ~~18~~ ~~17~~ 16 + 3 bytes, (non-competing)

Uses the `001` topology. Embedded in a Klein Bottle

```
1(/+@
-+)-($?/:1

```

## Explanation

Here is a gif of it running on 6:

The general way this works is it continually decrements the input down to zero each time multiplying a saved value by -1. That way the saved value will be negative if odd and positive if even.

### Setup

Right as the program begins running it does its set up

```
1(

```

This puts a 1 on the scope. This is the number we will multiply by -1 to keep track of the parity.

We then use a mirror to deflect the ip of the top of the screen. Since we are on a Klein Bottle and not a Torus this deflection will not only bring us to the bottom but also flip our horizontal coordinate. The ip will move upwards through mostly blank space until it hits another mirror. This mirror puts it in the main loop.

### Main Loop

In the main loop we make a duplicate of the input and decrement it by one, multiply the scoped value by -1 using `)-(` and then we switch the copied version of the counter with the original, we copied it earlier because `?` our conditional jump consumes a value. Since `?` skips the mirror we will run until our counter is zero.

However since we are checking the copy of the counter, we will actually exit when we hit -1. This is important because it saves us from having to make a value later.

### Cleanup

Once we hit zero we are deflected again but the mirror. This sends us over the top of the screen. Since we are on a Klein Bottle this twists us back around and causes the ip to collide with the `)` used in part of the code. This is convenient because it recalls the scoped value to the stack. We then get deflected by one of the mirrors from before. Lastly we add the two values, the counter and the saved value. The counter will always be `-1` so we are essentially just subtracting 1 from the saved value. The saved value will be either 1 or -1 so our result is either `-2` or `0`. Then we end and output using `@`.
> 2 votes

# Answer
# newline 19 bytes

```
g\n0\n/\n[\nd\n]

```

and the number `2`
> 2 votes

# Answer
# 17, 40 bytes

1 for odd, 0 for even. It takes input until a newline is entered and then prints mod 2 of last byte.

```
0{I : a == 0 @}1{0 @ 2 % $$}777{0 0 @}

```
> 2 votes

# Answer
# Whitespace, 30 bytes

```
[S S S T    S N
_Push_2][S N
S _Duplicate][S N
S _Duplicate][T N
T   T   _Read_STDIN_as_number][T    T   T   _Retrieve][S N
T   _Swap_top_two][T    S T T   _Modulo][T  N
S T _Output]

```

Letters `S` (space), `T` (tab), and `N` (new-line) added as highlighting only.
`[..._some_action]` added as explanation only.

Outputs `0` for even, `1` for odd.

Try it online.

**Explanation** (with `5` as input):

```
Command    Explanation             Stack      Heap     STDIN    STDOUT

SSSTSN     Push 2                  [2]        {}
SNS        Duplicate top (2)       [2,2]      {}
SNS        Duplicate top (2)       [2,2,2]    {}
TNTT       Read STDIN as number    [2,2]      {2:5}    5
TTT        Retrieve                [2,5]      {2:5}
SNT        Swap top two            [5,2]      {2:5}
TSTT       Modulo                  [1]        {2:5}
TNST       Output top as number    []         {2:5}             1

```
> 2 votes

# Answer
# Dodos, 13 bytes

```
	main dip dip

```

Try it online!

This program is composed by a single main function which decrements twice its number and then recurses. Due to how Dodos works, instead of infinitely recursing the first call that would go to a negative number will return its argument instead, which will be either 0 or 1.
> 2 votes

# Answer
# Python 2, 13 bytes

```
lambda n:~n&1

```

Try it online!

No shorter than the other non-REPL Python answers, but uses slightly different logic. Takes the bitwise complement of the input number (-x-1) and performs a BITWISE AND on it. Returns 1 if the complement is odd, and 0 if the complement is even - and therefore returns 1/0 if the original number was even/odd.

(Could be shortened by 1 byte by removing the complement ~ if 0=True and 1=False is allowable.)
> 2 votes

# Answer
# INTERCAL, 45 bytes

```
DOWRITEIN:1PLEASE:1<-:1~#1DOREADOUT:1DOGIVEUP

```

Try it online!

Prints 1 if the input is odd and 0 if the input is even.

...except this being the wonderful Compiler Language With No Pronounceable Acronym, 1 is printed as newline-I-newline while 0 is printed as underscore-newline-newline, and input has to have the individual digits spelled out in one of several natural languages or a mix thereof (such that the third test case, `16384`, is just as well English `ONE SIX THREE EIGHT FOUR` as Basque-Latin-Georgian-Tagalog-Kwakiutl `BAT SEX SAMI WALO MU`). Also, I'm not actually sure which INTERCAL dialect this is.

```
DO WRITE IN :1      Take a line of input and store the value in the variable :1.
PLEASE :1<-:1~#1    Politely reassign :1 to be the first bit of its old value.
DO READ OUT :1      Print :1 in "butchered Roman numerals".
DO GIVE UP          End the program.

```
> 2 votes

# Answer
# ZX80 (4K ROM) 23 tokenised BASIC bytes

```
 1 INPUT A
 2 PRINT A;":"; NOT A AND 1
 3 CONTINUE

```

This is a very simple solution as in Sinclair ZX80 BASIC, `PRINT 111 AND 1` will produce `1` (and therefore any odd number entered will produce `1` because in binary for any odd positive integer the zeroth bit is always set, so `PRINT 11 AND 1` will do `00001011 & 00000001` at the processor level more or less) - if we assume even is `true` then we can use `NOT` to invert the value, therefor `NOT 111 AND 1` will produce `0` or our `false` value.

Using the `CONTINUE` command will continue the symbolic listing from line `1`. You may also use `RUN` but both are equal in the basic tokens used.

## ZX80 (4K ROM) 16 tokenised BASIC bytes

If we assume that odd is our `true` value then we can remove some of the logic as follows (also saving bytes):

```
 1 INPUT A
 2 PRINT A;":";A AND 1
 3 RUN

```

There is one caveat; by using ZX80 BASIC, you may only enter 16-bit wide signed integers, so the range is -32768 to +32767 inclusive.

The same logic will work in Commodore BASIC (C64/VIC-20) so whilst both of the above will work, you may condense it into one line like `0inputa:printa":"aand1:goto`.
> 2 votes

# Answer
# Pyramid Scheme, ~~221~~ 199 bytes

```
   ^       ^ ^
  / \     /l\-
 /set\   /oop\
^-----^ ^-----^
-    ^- -^   / \
    ^-  /*\ /set\
   /#\ ^---^-----^
  ^---/-\  -    /-\
 /l\ ^---^     ^---^
/ine\-  /1\    -  /2\
-----   ---       ---

```

Try it online!

Outputs `0` for even and `1` for odd.

Pyramid Scheme has no modulus, no integer division, and no bitwise operators. The best approach I could conceive was repeatedly subtracting two from the input until either it or its predecessor is zero, then printing the final value.

This program translates rather easily to true Scheme. I have to say, that's my favorite part of this language—it's very nearly a Scheme dialect in its own right, despite being a joke!

```
(define n (read))
(do ()
    ((= 0 (* n (- n 1))))
  (set! n (- n 2)))
(display n)

```

Try it online!
> 2 votes

# Answer
# Keg, ~~2~~ 3 bytes

```
^2%

```

Last number outputted will be 1 if the number is odd, and 0 if it's even

Edit: Fixed for latest version

Try it Online!
> 2 votes

# Answer
# 05AB1E, 1 byte

```
É

```

Try it online!

## Explanation

```
   # implicit input
É  # push 1 if odd, otherwise push 0

```
> 2 votes

# Answer
# Cascade, ~~7~~ 5 bytes

```
#2&
%

```

Found a 2 bytes shorter solution by abusing wrapping Try it online!
> 2 votes

# Answer
# Toi, 6 bytes

```
(r[rr]

```

Try it online!

Toi is a language that only knows sets. The memory is a set S that starts as the empty set. The input number can be given as a von Neumann ordinal, constructed using `"ua"*n`, or alternatively the input number can be represented by the nesting level using `"u"*n`. `u` nests the context S, and `a` changes S to \\$S \cup \\{t \mid t \in s, s \in S\\}\\$ (from the esolangs wiki article).

`( cond [ stuff ]` is a while loop that performs `stuff` while applying `cond` on S yields a non-empty set. The commands in `cond` are unapplied before executing into `stuff`.

`r` changes S to \\$\\{t \mid t \in s, s \in S\\}\\$ essentially removes a layer of nesting. This effectively decrements the number represented by S by 1.

So, the meaning of `( r [ rr ]` is the following: while `r` on S is non-empty (i.e. while S-1 is not 0), perform `rr` (decrement S twice).

The parity is left on S, \\$\\{\\{\\}\\}\\$ if the input is odd, and \\$\\{\\}\\$ otherwise.
> 2 votes

# Answer
# RPL, 4 bytes

```
2MOD

```

Plain answer in vanilla RPL, for posterity and completeness of this thread.

As often with RPL, one byte is saved in the source code by removing a space between a number and a command. I assume this is rarely observed in Forth.
> 2 votes

# Answer
# Poetic, 190 bytes

```
although i agree i,a person,i was dismissive about a hell,i am not anarchic
i repeat:i know theres never a hell i am doomed to
actually,it seems a bit of a fraud,a lie,if He gives a man he|l

```

Try it online!

Input is in decimal. Output is an `Unexpected EOF` error for even inputs, and a `Mismatched IF/EIF` error for odd inputs. It takes forever to actually execute, though.

(Doesn't work for 0, but the question only specified *positive* inputs.)
> 2 votes

# Answer
# Python 3, 12 bytes

```
lambda n:n&1

```

Outputs 1 for odd, 0 for even.
> 2 votes

# Answer
# MAWP, 9 bytes

```
@!!2P2WA:

```

Try it!

Just a homemade modulo function. Outputs 1 if odd and 0 if even
> 2 votes

# Answer
## Google Sheets, 9 bytes

```
=MOD(A1,2

```

Google Sheets auto closes parenthesis. Its pretty self explanatory, it just does modulo 2 on the input (A1).
> 2 votes

# Answer
# sed, 5 bytes

```
/0$/d

```

Try it online!

Takes the input as a binary string. sed does not have truthy/falsey values, so I am defining truthy as a non-empty output and falsey as an empty output. As per this meta post, this is acceptable since these sets are non-overlapping.

For the cost of one byte, we can instead output by exit code:

```
/0$/q1

```

The following also works if input is taken as a binary list of digits, linefeed separated, but I don't think that's an acceptable input method.

```
$!d

```
> 2 votes

# Answer
# Factor, ~~5~~ 4 bytes

```
odd?

```

Try it online!

Outputs `t` if odd, `f` if even.

I feel a bit guilty doing this (and also stupid after Bubbler's suggestion).
> 2 votes

# Answer
# Add++, 5 bytes

```
?%2
o

```

Try it online!

Simple?
> 2 votes

# Answer
# TypeScript's Type System, No Ignore, 400 41 Bytes

```
type F<N>=N extends[...any,0|2|4|6|8]?1:0

```

TypeScript Playground

* Use Jacob's suggestion of checking the last number.

## Usage

```
// input is taken as an array (12 -> [1, 2])
type Test = F<[1,2]> // 1, the number is even

type Test2 = F<[1,1]> // 0, the number is odd.

```

The program checks if the last digit in the array is an even number.
> 2 votes

# Answer
## QBIC, ~~7~~ 5 bytes

```
:?a%2

```

This prints `0` for even values, and `1` for odds.

Explanation:

```
:   get a number from the cmd line args
?   PRINT
a%2 The input modulo 2 (1 for odds, 0 even)

```
> 1 votes

# Answer
# Brachylog, 3 bytes

```
%₂0

```

Try it online!

### Explanation

Well…

```
%₂0     Input mod 2 = 0

```
> 1 votes

# Answer
# Cardinal, 7 bytes

```
%++~:M.

```

Outputs truthy if odd falsy if even

Try it online!
> 1 votes

# Answer
# AHK, 21 Bytes

```
a=%1%
Send % Mod(a,2)

```

Once again, I can't use inputs directly in functions so I have to store it as another variable.
> 1 votes

# Answer
# C, 15 bytes

```
#define f(n)n&1

```

Returns 0 if even, 1 if odd.
> 1 votes

# Answer
# Common Lisp, 7 Bytes

```
#'evenp

```

Built-in function that checks parity. Barely beating Java!
> 1 votes

# Answer
# \>\<\>, 4 + 3 = 7 bytes

Outputs 1 for odd and 0 for even. Execute using `-v` (+ 3 bytes).

```
2%n;

```

Try it online!
> 1 votes

# Answer
## dc, 4 bytes

Output is 1 for odd, and 0 for even.

```
?2%p     # read input, push 2, do modulo, print

```

**Try it online!**

I think for stack-based languages, I can assume the input is already on the stack, and that I can leave the output on top when done. This would be similar to how I/O is allowed for functions.

**Stack I/O**: 2 bytes

```
2%

```
> 1 votes

# Answer
# , ~~8~~ ~~7~~ 6 bytes

```
Àé1òhD

```

Try it online!

Outputs `1` for odd numbers and nothing (an empty string) for even numbers.

```
Àé1                   " argument times insert a 1
                      " this converts input to unary
                      " and now the cursor is at the end of the line
   ò                  " recursively do:
    h                 "  move 1 to the left and
     D                "  delete everything from the cursor to the end of the line
                      "  this effectively removes 2 characters at once until
                      "  a breaking error occurs at which point
                      " implicit ending ò

```
> 1 votes

# Answer
# Befunge 93, 5 bytes

```
&2%.@

```

Try it Online!

```
&        Take input
 2%      Mod 2
   .@    Print and exit

```

This answer is very similar to Befunge 98, but it needs the `@` to end because `&` pushes the last number in the input on EOF
> 1 votes

# Answer
# yup, 15 bytes

```
{0e0:e---}00e--

```

Try it online!

Much nicer than I thought it might be! I don't presently have a modulus algorithm (though there most likely is one), but this is considerably simpler. It takes input from the stack and leaves output on the stack.

## Explanation

```
{0e0:e---}00e--   stack     | explanation
                  [n]       | input from top of stack
{        }        while top of stack is positive:
 0                [n 0]     | push 0
  e               [n 1]     | pop x, push e^x
   0              [n 1 0]   | push 0
    :             [n 1 0 0] | duplicate
     e            [n 1 0 1] | pop x, push e^x
      -           |n 1 -1]  | subtract
       -          [n 2]     | subtract
        -         [n-2]     | subtract
                  now, either -1 is on the stack for odd, or 0 for even
          0       [c 0]     | push 0
           0      [c 0 0]   | push 0
            e     [c 0 1]   | pop x; push e^x
             -    [c -1]    | subtract
              -   [c+1]     | subtract (adds)

```
> 1 votes

# Answer
# Befunge 98, 4 bytes

```
&2%.

```

Try it Online! (It may take a while because of how it ends)

```
&       Take input
 2%     Mod 2
   .    Print
&       The IP wraps around and hits the "take input" again. Because of the
        way TIO's '98 handles & on EOF, this ends the program after a minute.

```

This answer is very similar to Befunge 93, but doesn't need the `@` to end.
> 1 votes

# Answer
# J, 3 bytes

```
2&|

```

Explanation:

```
2&|
  |    this does mod, only with the order of the operands reversed
2      the number 2... derp
 &     attaches 2 to | so it can be the left operand
       the right operand is implied due to tacit programming

```
> 1 votes

# Answer
## Bash + coreutils, 11 bytes

Output is 1 for odd numbers, and nothing for even ones. This is a full program. There is another bash answer by Digital Trauma, but that one is a function, however it is in pure bash.

```
seq $[$1%2]          # give 'input % 2' as argument to seq. Notice that 'seq 0'
                     #doesn't print anything.

```

**Try it online!**

I use `seq`, because it is 1 byte shorter than `echo`, but it has a different truthy / falsy mapping.
> 1 votes

# Answer
## Ook!, ~~79~~ 64 bytes

**Update:** 15 bytes shorter by removing the whitespaces, thanks to Okx.

This is a joke esoteric language, meant to be trivially isomorphic to brainfuck by substituting each command with an Orangutan phrase. This is my first time using it.

```
Ook.Ook.Ook!Ook?Ook.Ook!Ook.Ook?Ook.Ook!Ook?Ook!Ook?Ook.Ook!Ook.

```

**Try it here!** Give input as unary. Output is 1 for odd numbers, and nothing for even ones.

**Explanation:**

The above script is a direct translation of the 8 bytes brainfuck answer by @Dennis:

```
+[,>,]<.

```

Ook! has only 3 distinct syntax elements: `Ook.`, `Ook?` and `Ook!`. These are combined into groups of two, and the various pair combinations are mapped to the brainfuck commands.

**Substitution table:**

```
>   Ook.Ook?
<   Ook?Ook.
+   Ook.Ook.
-   Ook!Ook!
.   Ook!Ook.
,   Ook.Ook!
[   Ook!Ook?
]   Ook?Ook!

```
> 1 votes

# Answer
# tinylisp, 18 bytes

There's a library function for that.

```
(load library)odd?

```

The function itself is `odd?`--call it like `(odd? 12)`. Try it online!

Writing a function from scratch is **28 bytes** (TIO):

```
(d o(q((n)(i(l n 2)n(o(s n 2

```

This defines `o` as: if `n` is less than 2, return `n`, else recurse with `n-2`.
> 1 votes

# Answer
# LibreLogo, 19 bytes

**Code:**

```
print int input "%2

```

**Result:**

Returns 0 for even numbers, and 1 for odd numbers.
> 1 votes

# Answer
# Pip, 3 bytes

```
a%2

```

Try it online!

Explanation:

```
a   is auto-read from the command line
%2  Modulo 2 --> yields a 0 for even, 1 for odd
    The result of the last statement is auto-printed.

```
> 1 votes

# Answer
## Jellyfish, 6 bytes

```
p|i
 2

```

Try it online!

Print (`p`) the input (`i`) modulo (`|`) two (`2`).
> 1 votes

# Answer
# Dogescript, ~~32~~ 29 bytes

```
such f much n
return n%2
wow

```

Returns `1` if `n` is odd, `0` otherwise.
> 1 votes

# Answer
# Carrot, 5 bytes

```
#^F%2

```

Try it online!

Note: this is a trivial answer. Please do not vote. I am only posting this for completion.

### Explanation

```
#^                // set the stack to the input
  F               // convert it to a float
   %2             // take the modulo 2 of it
                  // implicit output

```
> 1 votes

# Answer
# APL (Dyalog), 3 bytes

Full program body:

```
2|⎕

```

Try it online!

Alternatively:

```
2⊤⎕

```

Try it online!

`|` is modulus,  is base-convert,  is numeric input prompt. Handles any numeric array.

I've found 40 functions which can also do the job in 3 bytes. List and try them all online!
> 1 votes

# Answer
# Haxe, 22 bytes

```
function(x)return x%2;

```

Test it online!

Haxe is a high-level, strictly typed language designed to be compiled across many different platforms. While it doesn't have any form of lambda expressions, it does have one unique property that allows for interesting golfing: everything is an expression. This allows you to do interesting things that aren't possible in most similar languages, such as `b>0&&return b`. In this particular case, it allows us to remove the brackets that would normally be required in a function definition.
> 1 votes

# Answer
# braingasm, 3 bytes

Takes input from stdin, prints `0` for even and `1` for odd.

```
;o:

```

`;` reads an integer, `o` checks the "oddity" (opposite of parity), `:` prints an integer.

edit: changed to `p` to `o` to retrofit to a breaking change in the language.
> 1 votes

# Answer
# Qwerty-RPN, 4 bytes

```
@2%#

```

Explanation:

```
@    Input number
  %  ...modulo...
 2   2
   # print

```
> 1 votes

# Answer
# Beeswax, 6 bytes

```
_2~,%{

```

Explanation:

```
_        Create a bee flying horizontally   [0,0,0]
 2       Set top to 2                       [0,0,2]
  ~      Swap top and 2nd values            [0,2,0]
   ,     Take value from STDIN as int       [0,2,7]
    %    Modulo: top % 2nd                  [0,0,1]
     {   Print top                          [0,0,1]

```

Try it online!
> 1 votes

# Answer
## Gibberish, 8 bytes

```
eli2gmeo

eli      - read line, convert to integer
   2gm   - push 2, push modulo of previous value by 2
      eo - output stack

```

Outout 0 for even and 1 for odd
> 1 votes

# Answer
# Elisp, 12 10 bytes

```
(%(read)2)

```

(read) evaluates to the input, and the (% ...) expression is then evaluated. Outputs 1 for odd, 0 for even.

Test cases:

(Input):(Output)
1:1
2:0
16384:0
99999999:1

Edit: Saves 2 bytes thanks to @Dylan, for asking if it was possible to leave out the spaces in a Elisp expression. Turns out the answer is yes!
> 1 votes

# Answer
**J, 8 chars**

```
<&1@:|~&2

```

It's just a composition of

```
<&1

```

which flips 0 for 1, and

```
|~&2

```

which is mod 2.

The `@:` just composes the two functions together
> 1 votes

# Answer
# Scala, ~~15~~ ~~14~~ ~~5~~ 3 bytes

```
_%2

```

Returns 0 if it's an even number and 1 if it's odd

This is equivalent to `(i:Int)=>i%2`.
However, this needs to be assigned to a variable of type Int=\>Int, otherwise the compiler will complain.
The whole code would look like this:

```
val x: Int => Int = _%2

```
> 1 votes

# Answer
## Python REPL, 3 bytes

```
_&1

```

**Explanation:** Taking bitwise and with 1 gives True when even else False
> 1 votes

# Answer
# J, 2 bytes

```
2|         NB. remainder of arg / 2

    So 0 = true (even), 1 = false (odd)
    2| 7   => 1
    2| 10  => 0

```
> 1 votes

# Answer
# *Acc!!*, 43 bytes

```
N
Count i while _/10 {
N-_%2*2
}
Write _+41

```

Because of quirks of the input mechanism in *Acc!!*, the input number (given on stdin) has to be terminated with a signal value--in this case, a `tab` character. The code outputs `2` if the number is even, `0` if it is odd.

### Explanation

```
# Read a character's ASCII value into the accumulator
N
# Loop while accumulator intdiv 10 is greater than 0 (i.e. acc >= 10)
Count i while _/10 {
    # Read another ASCII value, subtract (current acc % 2) * 2, and store back to acc
    N-_%2*2
}
# At the end of the loop, we know we just read a tab character (ASCII 9). This means the
# acc value is 9 if the previous digit had an even ASCII value, or 7 if it was odd. We
# add 41 to convert to the ASCII codes of 2 and 0, respectively, and write to stdout.
Write _+41

```
> 1 votes

# Answer
# Scala, 9 bytes

```
(_:Int)%2

```

This outputs 1 for odd, 0 for even
> 1 votes

# Answer
# Swift, 18 bytes

```
let f={n in n%2<1}

```
> 1 votes

# Answer
# J-uby, 5 Bytes

```
~:%&2

```

Takes the reversed-arguments version of `%` and partially applies 2 to it, creating a function which takes `x` and returns `x%2`. `0` for even, `1` for odd.
> 1 votes

# Answer
# REXX 13 BYTES

```
say arg(1)//2

```

Try it here

REXX functions and instructions
> 1 votes

# Answer
# Actually, 2 bytes

```
1&

```

Try it online!

Output is `0` if even, `1` if odd. The code is very straightforward: bitwise-AND (`&`) with `1` (return low bit of input).
> 1 votes

# Answer
# WC, 40 bytes

WIP mini language I created.

```
;>_0|;>(?#@8|!@3|//##@2|!@2|//#$-$-/)*$

```

Explanation:

```
;>_0|          New var using the first artifact (the input number)
;>(            Start a new function
  ?            Select the first variable (reset var index)
  #@8|         Start if statement with 9th global ("-1") as condition
    !@3|       Print the 4th global ("1")
    //         Terminate program
  #            End if statement
  #@2|         Start if statement with 3rd global ("0") as condition
    !@2|       Print the 3rd global ("0")
    //         Terminate program
  #            End if statement
  $-$-         Decrement the current variable twice
  /            Restart context (the current function)
)              End function
*$             Call the current variable (the function)

```

Try it online!
> 1 votes

# Answer
# Common Lisp, 4 bytes

```
oddp

```

Builtin function, like Haskell `odd`.
> 1 votes

# Answer
# Check, 4 bytes

```
>2%p

```

Explanation: `>2` pushes 2 onto the stack, `%` preforms modulus with the implicit input, and then `p` prints the result.
> 1 votes

# Answer
# ,,,, 1 byte

```
œ

```

Yeah, yeah, a builtin... For anybody wondering about the choice of character, it's supposed to be *odd or even* or *o or e*.

However, I do have other solutions.

## 2 bytes

```
1&

```

### Explanation

```
1&

    implicit input
1   push 1
 &  pop input and 1 and push input & 1 (bitwise AND)
    implicit output

```

## 2 bytes

```
2%

```

### Explanation

```
2%

    implicit input
2   push 2
 %  pop input and 2 and push input % 2 (modulo)
    implicit output

```
> 1 votes

# Answer
# WolframAlpha, 6 bytes

```
x mod2

```

Try it online!

This will output `0` if the value is divisible by `2` and a non-zero value ("truthy") otherwise.

However, if that is not good enough, there's an alternative **11-byte** solution using the floor function:

```
⌊x⌋mod2

```

Try it online!

*Note*: Byte count in UTF-8 counted using this resource.

---
> 1 votes

# Answer
# Aceto, 5 bytes

```
ri2%p

```

```
r reads input
i converts to integer
2% takes the number modulo 2
p prints the answer

```

Try it online!
> 1 votes

# Answer
# SNOBOL4 (CSNOBOL4), ~~30~~ 27 bytes

```
	OUTPUT =REMDR(INPUT,2)
END

```

Try it online!

Prints `1` for odd, `0` for even.

SNOBOL doesn't have true or false and all conditions are done on `SUCCESS` or `FAILURE` so this is sort of truthy?
> 1 votes

# Answer
# Underload, 5 bytes

```
():aS

```

Underload doesn't really have a concept of Truthy/Falsey, so this is empty/nonempty output for odd/even respectively.

Input should be in unary (as some number of `~`) between the `a` and the `S`.

## Explanation

`()` pushes the empty string. `:` duplicates it and `()` wraps the top stack element in parenthesis, meaning the stack now looks like `"", "()"`. The input now appears in the program, meaning it is executed as code. `~` is the swap instruction in Underload, meaning that an even input is an even number of swaps, which doesn't affect the stack, and an odd input is an odd number of swaps, which has the same effect as a single swap. `S` outputs the top stack element, which will be either `()` if the input was even, and  if the output was odd.

I mentioned that Underload doesn't have Truthy/Falsey, but the common way to represent booleans as Underload code that either swaps or doesn't swap, meaning that the cheaty one-byte program `S` technically works as a valid submission.
> 1 votes

# Answer
# Pyt, 2 bytes

```
2%

```

Explanation

```
            Implicit input
2%          Mod 2
            Implicit print

```

Odd is truthy, even is falsy

Try it online!

---

Alternatively, also 2 bytes

```
2|

```

Explanation:

```
            Implicit input
2|          Is it divisible by 2?
            Implicit output

```

Even is truthy, odd is falsy

Try it online!
> 1 votes

# Answer
# Piet, 10 codels

Test using this online interpreter, with codel size 40.

Does what you might expect: take input, push `2`, apply the `mod` operation, and output the result. The program then terminates due to the J-shape at the right-hand edge.

Odd (respectively, even) input corresponds to output of `1` (respectively, `0`).

Note: the lower-left-hand codel could be changed to black, white, or almost any other color without changing the program's behavior. However, if that codel is changed to "dark green" to match the codel to its right, then the program will calculate the remainder modulo `3` instead of `2`.

So this program can trivially be modified to become a mod-3 calculator, with the same number of codels.

### Bonus mod-3 calculator (not an answer to this challenge):
> 1 votes

# Answer
# Perl 5, 6 bytes

Add `+1` for `-p`

```
#!/usr/bin/perl -p
$_%=2

```

Try it online!
> 1 votes

# Answer
# Tcl, 19 bytes

```
puts [expr $argv%2]

```

Try it online!
> 1 votes

# Answer
# Z80Golf, ~~9~~ 8 bytes

```
00000000: d5d2 0380 e601 ff76                      .......v

```

Try it online!

### Disassembly

```
start:
  push de
  jp nc, $8003
  and 1
  rst $38
  halt

```

Golfed a byte using the "input loop at start" pattern:

```
  push de      ; Push 00 00 (return address) to the stack
  jp nc, $8003 ; Escape the loop if carry is set (EOF)
               ; otherwise take next input and return to the start of the program

```

---

## Previous solution, 9 bytes

```
00000000: cd03 8030 fbe6 01ff 76                   ...0....v

```

Try it online!

### Disassembly

```
start:
  call $8003
  jr nc, start
  and 1
  rst $38
  halt

```

Accepts the decimal input (binary, octal, hexadecimal, or any other even base would work), and outputs ASCII 0 for even, 1 for odd.

`call $8003` calls `getchar`, which stores the next char to register `a`, or sets the carry flag on EOF. Since the only significant data is the last char, the program simply calls `getchar` repeatedly until EOF. `and 1` takes the parity, `rst $38` is a golf idiom for `call putchar`, and `halt` terminates the program.

## 9 bytes, Human-readable output

```
00000000: cd03 8030 fbe6 31ff 76                   ...0....v

```

Try it online!

Limiting the input to decimal or lower even bases, we can get more readable result (`'0' = $30` and `'1' = $31`) by changing `and 1` into `and $31`. Also works for hexadecimal if you use `0123456789pqrstu`, case sensitive :)
> 1 votes

# Answer
# Flobnar, 6 bytes

```
&
%@
2

```

Try it online! (requires the `-d` flag)

I don't think it's going to get much shorter than this.
> 1 votes

# Answer
## CHIP-8 assembly, 22 bytes

```
0x6001 F10A 410F 120C 8210 1202 8226 8F03 FF29 D005 1214

```

Takes in a number entered by the user, until it is terminated by the user pressing the `F` key, and prints out to the screen 0 if it's odd, or 1 if it's even.

The CHIP-8 had 16 8-bit registries (`V0` to `VF`), with `VF` mostly being used for carry operations. The ROM was loaded into memory at address `0x200`, which is why the jump operations are offset. It also contained display-representations of the numbers 0-9 and letters A-F in memory at `0x00`, so that a programmer need not create them.

The code works like this:

```
0x200:      60 01        Set V0 to 0x01.
0x202:      F1 0A        Wait for a key to be pressed, and enters the value into V1.
0x204:      41 0F        Skip the next instruction if V1 does not equal 0x0F.
0x206:      12 0C        Jump to instruction address 0x20C.
0x208:      82 10        Assign the value of V1 into V2.
0x20A:      12 02        Jump to instruction address 0x202.
0x20C:      82 26        Store the least significant bit of V2 into VF, left-shift V2 by one bit, and store the shifted value into V2.
0x20E:      8F 03        Set VF to VF XOR V0 (V0 is set previously to 1, so this is equivalent to NOT VF).
0x210:      FF 29        Set the memory address pointer (I) to the character representation of the value in VF.
0x212:      D0 05        Draw the data from the address pointer I to the screen, at pixel (0, 0), with a width of 5 pixels (the height is always 8 pixels).
0x214:      12 14        Jump to instruction address 0x214 (i.e., loop indefinitely).

```
> 1 votes

# Answer
# Little Man Computer, 31 bytes, 5 instructions

```
INP
SUB 5
BRP 1
ADD 5
OUT
DAT 2

```

Which boils down to this once assembled into RAM:

```
901 205 801 105 902 002

```

Outputs \\$ 1 \\$ for an odd number and \\$ 0 \\$ for an even number.

A online emulator can be found here, though you may need to increase the speed to avoid waiting a painfully long time (if anyone finds a better online version, please enlighten me).
> 1 votes

# Answer
# Alchemist, ~~79~~ 35 bytes

-43 bytes thanks to ASCII-only!!

-1 byte thanks to Jo King!

```
_->s+In_i
e+i->
0e+i->e
s+0i->Out_e

```

Outputs `0` for even and `1` for odd, try it online!

## Ungolfed
> 1 votes

# Answer
# Come Here, 68 bytes

```
ASKi0CALLi*256iCOME FROM SGN(i//256)1CALL(i//256)iTELL48+(iMOD2)NEXT

```

Less golfed:

```
ASK i
0 CALL i*256 i
COME FROM SGN(i//256)
1 CALL (i//256) i
TELL 48 + (i MOD 2) NEXT

```

---

COME HERE uses integers internally, but handles input and output as strings; unfortunately, the string encoding it uses really isn't all that helpful for working with input as numbers. In this case, we have to repeatedly divide by 256 until we get a value that is less than 256, in order to get the last character.

If little-endian (rather than big-endian) input is allowed, we can use this shorter version (22 bytes) instead:

```
ASKiTELL48+(iMOD2)NEXT

```

Prints 0 for even, and 1 for odd.
> 1 votes

# Answer
# MineFriff, 7 bytes

```
Ii2,%o;

```

Explanation:

```
Ii` {Change the input mode to (I)nteger and take input}
2,` {Push 2 onto the stack}
%o` {x % 2 and output}
;   {end prog}

```
> 1 votes

# Answer
# Ruby, 6 bytes

```
n.odd?

```

Try it online!

I don't know if this is cheating. There's a method definition in the header. Is there a way to skip doing this and pass in a number differently, perhaps?

`odd?` is a default operation in Ruby.
> 1 votes

# Answer
# Commodore BASIC (C64/128, VIC-20, TheC64/Mini, C16/+4) - 21 tokenized bytes

In this one, `odd` numbers produce a `TRUE` value and `even` numbers produce a `FALSE` (though on Commodore BASIC, `FALSE` is zero and `TRUE` is negative one; it does not do this, more conforms to modern-days `TRUE`/`FALSE` integer equivalents)

```
 0 inputa:ifatH?a":"aaN1

```

Expanded and non-minimised as:

```
 0 input a
 1 if a then print a; ":"; a and 1

```
> 1 votes

# Answer
# MarioLANG, 37 bytes

```
;>-)+([!)
="=====#:
)![(-)-<
:#====="

```

Try it online!

Outputs 1 for odd and 0 for even.
> 1 votes

# Answer
## Kotlin, 15 bytes

```
{n:Int->n%2<1}

```
> 1 votes

# Answer
## , 2 bytes

```
2m

```

Basically just modulo by 2...
> 1 votes

# Answer
# Brainetry `-w 2`, 25 bytes

Golfed version:

```
a b c d e f
a b c d e f g

```

How it works: we set the cell size to `2` with `-w 2` which pretty much does all the """heavy""" lifting for us. After that we just input one number and output it. If you want to input an actual number instead of an ASCII code point you can also set the `--numeric-io` flag.

The golfed version was adapted from the program at the end of this answer. To try this online you can

* head over to this replit link, copy&paste the code into the `btry/replit.btry` file and hit the green "Run" button;
* clone the github repo and from your terminal run `./brainetry btry/ppcg/even_or_odd.btry --numeric-io -w 2`.

```
Let me read one input number
and now I will ouput its parity.

```
> 1 votes

# Answer
# Pyramid Scheme, ~~108~~ 92 bytes

```
   ^
  /-\
 ^---^
 -^ ^-
  -^-
  /^\
 ^---^
 -^ /#\
 /-\---^
/ 1 \ /l\
-----/ine\
     -----

```

Try it online!

Outputs `-2` for odd numbers and `0` for even ones. This can be swapped by switching the top pyramid for `+` instead of `-`. This is basically equivalent to `(-1)**int(input) - (-1)**0`
> 1 votes

# Answer
## Microsoft Word Math Autocorrect, 40 bytes

Add the following entries to your Math Autocorrect table:

```
0$ -> $0
1$ -> $1
2$ -> $0
3$ -> $1
4$ -> $0
5$ -> $1
6$ -> $0
7$ -> $1
8$ -> $0
9$ -> $1

```

Then make a new equation. Separate each digit with a space, or this will not work. When you type your last digit, it will be replaced by either a $1 (if it's odd) or $0 (if it's even).

For example, to input the number 942, type `9 4 2$`, which becomes `9 4 $1`, telling me it's odd. As a bonus, this works for all even bases up to 10.
> 1 votes

# Answer
# MAWP, 36 bytes

```
%@_1A[1A~25WWM~]%[{1A{1M}<0:.>}2A]1:

```

## Explanation

It uses the same logic as all the other programs, but MAWP does not have a modulo operator.

The workaround is repeately deducting 2 from the number until we reach 0 or 1.

```
%@_1A[1A~25WWM~]% snippet used for inputting multi digit numbers
[                 loop if top of stack != 0
 {1A{1M}<0:.>}    if number-1=0 print 0 and end program
2A]               subtract 2 from the number
1:                once loop ends, print 1

```

4 digit and higher numbers take *very* long to check in the online interpreter.

Try it!
> 1 votes

# Answer
# dotcomma, 74 bytes

```
[[,.][.][.].,].[[[[,.][[].[],][[].[],].,][[,][[].[],][[].[],].],[],.][.].]

```

Dotcomma is a language I recently invented, designed to do things in an interesting way with as few instructions as possible. In order to accomplish this, there are two operators (predicatably `.` and `,`) which can do entirely different things depending on context. This answer's explanation will be a somewhat high level explanation of how this program works. To see some simpler examples, check out the examples in the page linked in the title.

The first part of this program, `[[,.][.][.].,]`, adds `2` to the inputted number. The `[,.]` block will take a number from the queue (which will contain the input), add it to two `[.]` blocks (equal to `1` each), and put it back in the queue. The `.` between the two main blocks creates a loop.

To make the loop easier to understand, here's the code broken into more manageable pieces:

```
[[,.][.][.].,].[
  [
    [[,.][[].[],][[].[],].,]
    [[,][[].[],][[].[],].],[],.
  ][.].
]

```

The first part of the loop, on line 3, will take the current number from the queue and subtract `2` from it. It then puts it back in the queue, and the second part tests whether that number minus `2` is negative. If so, the loop ends.

The result is the number in the queue being either `0` if the input was even, or `1` if the input was odd.
> 1 votes

# Answer
# !@#$%^&\*()\_+, ~~14~~ 9 bytes

```
^(1*1*)+#

```

(`1` represents character `\x01`.)

Try it online!

~~Someone created an Esowiki page for this language and put a badly-golfed parity program there, which motivated me to create this program. It inputs n and inverts 0 n times.~~

I only now noticed I made an answer for this challenge, so I decided to golf it. This is a straightforward port of Dennis' BF answer. Input is unary with the character `\x00`. Output 1 if it's odd.

Find this unsatisfying? Here's output 1 if it's *even*, in still 9 bytes.

```
^(2**)+*#

```
> 1 votes

# Answer
# Bound, 3 bytes

```
i?.

```

Explanation:

```
i # Gets input and adds to stack if its an integer
? # Pops the top element and check if its even (0 is false, 1 is true)
. # Displays the stack

```

Try it online!
> 1 votes

# Answer
# Kotlin, 19 bytes

```
fun a(n:Int)=n%2==0

```

This was surprisingly simple. And the code is pretty self explanatory.
> 1 votes

# Answer
# ARM Thumb-2 machine code, 4 bytes

```
07c0 4770

```

```
        .syntax unified
        .arch armv6t2
        .thumb
        .globl is_odd
        .thumb_func
        // Standard C calling convention
        // Input: uint32_t r0
        // Output: r0 == 0 if even, else odd
is_odd:
        // Shift out everything but the lowest
        // bit, leaving odd numbers as
        // 0x80000000 and even numbers as 0.
        lsls    r0, r0, #31
        // Return
        bx      lr

```

Very simple. Shifts everything but the lowest bit into oblivion via `lsls` and returns.

Odd numbers will return nonzero and even numbers will return zero. It follows standard C calling convention.

```
0x01234567 << 31 = 0x80000000
0x12345678 << 31 = 0x00000000

```

You can't get any shorter than that.

For the reference, `and{s} r0, #1` is a wide instruction.
> 1 votes

# Answer
# Python - 24 bytes

```
n=int(input())
print(n%2)

```

Hooray for built-ins! This program should be fairly easy to understand. Assumes n has *not* been inputted already into the program. If it has, only the second line is necessary, and this can be golfed down to 10 bytes.
> 1 votes

# Answer
# Stack Cats \+ `-mn`, 6 bytes

```
[:^*_:

```

Try it online!

mirrored (done with `-m` flag):

```
[:^*_:_*^:]

```

Returns `1` for odd and and `-1` for even. The `n` flag is used for numeric, rather than codepoint io.

Stack Cats is a very interesting language. Stack Cats performs operations on an infinite tape of bottomless stacks of arbitrary precision integers. It requires mirror symmetry, and most of the mirroring exactly undoes the previous operation. Despite this, Stack Cats is Turing complete, and that is most easily achieved by using a `<(...)*(...)>` construct that skips the entire first half. However, that construct would require more bytes than the approach I used. The first part `[:^` moves the input to the top of the next stack and duplicates it. Since the inputs are terminated with `-1` the stacks now looks like this:

```
         [i]
... [-1] [i] ...
          ^

```

where `i` is the input. The next part `*_` determines the parity of the input by subtracting the input from the input with its least significant bit flipped, leaving `1` for odd, or `-1` for even. The stacks now look like this:

```
         [r]
... [-1] [i] ...
          ^

```

where `i` is the input and `r` is the result. Next comes the hard part: ensuring the first half doesn't undo the second. That is done by a single `:` which flips the top two values of the stack, which now looks like this:

```
         [i]
... [-1] [r] ....
          ^

```

`_*^` then performs some operations on the input, leaving random garbage in its place, and the result unchanged. The final `:]` moves the result to a place it is printed (because the current stack is outputted, without any trailing `-1`s). The final stack looks like:

```
    [r]
... [-1] [random garbage] ...
     ^

```
> 1 votes

# Answer
# APL (Dyalog Unicode), 11 bytes

```
⎕←2|⎕

```

Try it online!

Explanation:

```
⎕← print to stdout
2| parity of
⎕ input

```
> 1 votes

# Answer
## Desmos, 12 bytes

```
mod(i,2)
i=0

```

1 is falsey odd number and 0 is truthy even number.

Try it: https://www.desmos.com/calculator/hhhbhdkkbl
> 1 votes

# Answer
# Excel VBA, 9 bytes

An anonymous immediate window function that bit masks all but the lowest bit of input from range `[A1]` and outputs to the immediate window

```
?1And[A1]

```
> 1 votes

# Answer
# K (ngn/k), ~~5~~ 2 bytes

```
2!

```

Try it online!

*-3 bytes thanks to Jo King*

0 for true, 1 for false.
> 1 votes

# Answer
## Pascal, ≥ 6 B

```
odd(x)

```

where `x` is an `integer` variable or expression returns the `Boolean` value `true` if `x mod 2 = 1`, otherwise `false`.
> 1 votes

# Answer
# GBZ80 machine code, 1 byte

Given an input in register A, this outputs in the carry flag such that 1 is odd and 0 is even.

```
0F

```

Disassembly:

```
rrca

```

This instruction rotates register A right once, but with the carry flag treated as bit -1 only for the right end. This instruction can be confused with `rrc a`, which is a two byte (`CB 0F`) instruction using a genericized pattern for other registers and which updates the zero flag.

Bit 0 determines parity. Performing a rotation right through carry puts bit 0 in the carry flag.
> 1 votes

# Answer
# C (gcc), 10 bytes

Uses the `-D` compiler flag to define a macro.

```
-Df(i)=i&1

```

Try it online!
> 1 votes

# Answer
# Thunno 2, 1 byte

```
E

```

Attempt This Online! Uses \\$1\\$ (true) for even, and \\$0\\$ (false) for odd.

```
ɗ

```

Attempt This Online! Uses \\$0\\$ (false) for even, and \\$1\\$ (true) for odd.
> 1 votes

# Answer
# (,) `ds`, ~~16~~ 14 Chars or \\$14\log\_{256}(3)\approx\\$ 2.77 Bytes

```
((()),,((())))

```

Accepts input in unary as a sequence of null bytes (easiest way to make it is by adding %00 to the input section in the URL), and outputs -1 for odd and 0 for even.

TIO
> 1 votes

# Answer
# PARI/GP, 6 bytes

```
n->n%2

```

Mod 2.
> 0 votes

# Answer
# CJam, 4 bytes

```
q~2%

```

Try it online!

Simple mod by 2. Outputs `1` for odd, `0` for even.
> 0 votes

# Answer
# Java, 91 bytes

```
enum d{;public static void main(String[]a){System.out.println(Long.parseLong(a[0])%2==0);}}

```

Takes number as first command line argument and outputs to STDOUT.
> 0 votes

# Answer
## bc, 9 bytes

Output is 1 for odd, and 0 for even.

```
read()%2

```

**Try it online!**

A trailing newline is necessary to run successful, and it is included in the bytes count. The `read()` function works only for numerical input.
> 0 votes

# Answer
# Applescript function, 26

```
on f(i)
return i mod 2
end

```

# Test calls

```
log f(1)
log f(2)
log f(3)

```
> 0 votes

# Answer
# Go, 26 bytes

```
func(i int)int{return^i&1}

```

Returns 1 for even and 0 for odd.

Try it online!
> 0 votes

# Answer
# √ å ı ¥ ® Ï Ø ¿ , 4 bytes

```
Ik@o

```

Try it online!

Ignore the header/footer on TIO; that's the interpreter for √ å ı ¥ ® Ï Ø ¿

Not as trivial as the other answers that use builtins or `%`. Outputs `0` for odd and `1` for even.

```
I    - Take input
 k   - Remove all odd numbers from the stack
  @  - Push the length of the stack
   o - Output

```

If the input is odd, it is removed from the stack and the length pushed is 0.

If it's even however the length will be 1 (the input)
> 0 votes

# Answer
# Python 2, 16 bytes

```
print(input()%2)

```

Try it online!
> 0 votes

# Answer
# Chip, 2 bytes

For the simple case:

```
Aa

```

This only handles one-byte numbers, either a single ASCII digit or a 1 byte unsigned integer (because ASCII code points for odd digits are themselves odd). This works like the `&1` bitmask used in many other answers. If multiple bytes are provided, this will treat each new byte as a separate input. Outputs `0x0` for even and `0x1` for odd.

By adding `e*f`, we can get output in ASCII (**5 bytes**):

```
Aae*f

```

Try it online!

# 23 + 3 = 26 bytes

For the complex case:

```
 Svvvvvvvv~t
azABCDEFGH

```

This handles numbers of any length, ASCII or unsigned integer as before (big endian so that least significant bit is still last). Requires either a null terminator, or the `-z` flag (as shown in the byte count) to detect the end on the input. Like above, outputs `0x0` for even and `0x1` for odd.

Again, we can add `e*f` to get ASCII output (**25 + 3 = 28 bytes**):

```
*fSvvvvvvvv~t
eazABCDEFGH

```

Try it online!
> 0 votes

# Answer
# JavaScript, 6 bytes

A function of input *n* that returns 0 if even and 1 if odd.

```
n=>n%2

```
> 0 votes

# Answer
# x86 machine code, 2 bytes

```
00000000  a8 01                                             |..|
00000002

```

Sets the zero flag if the value in register A is even.
> 0 votes

# Answer
# R, 10 bytes

```
!scan()%%2

```

If you can get away with assuming n is the value, !n%%2 works.
> 0 votes

# Answer
# Convex, 3 bytes

```
Ã2%

```

Try it online!
> 0 votes

# Answer
# Python 3, 21 bytes

```
print(int(input())%2)

```

Try it online!
> 0 votes

# Answer
# ///, 5 bytes

```
/00//

```

Try it online!

Takes input in unary. Input goes after the last `/`. Prints a `0` of it's even, otherwise prints nothing. Incredibly short for a /// program that actually does soething.
> 0 votes

# Answer
# x86 machine code, 3 bytes

83 E0 01 (and ax, 1 in nasm)

Explanation:

Anding any number with 1 will return 1 if the number is odd, or 0 if it is even.

```
 1111 (15)
&0001
-----
 0001

 1110 (14)
&0001
-----
 0000

 0001 (1)
&0001
-----
 0001

 0010 (2)
&0001
-----
 0000

```

So move a number into AX, use the three bytes, and AX will hold 0 or 1, if the number is even or odd.
> 0 votes

# Answer
# Casio-Basic, 9 bytes

```
mod(n,2)

```

8 bytes for the function, 1 to add `n` as an argument.
> 0 votes

# Answer
# Triangular, 6 bytes

```
$.2%m<

```

Prints `0` for even, `1` for odd. Try it online!

```
  $
 . 2
% m <

```

`$` reads an integer to the stack. `2` pushes 2 to the stack. `m` divides the top two stack values and pushes the remainder. `%` prints as an integer.
> 0 votes

# Answer
# Implicit, 2 bytes

```
_2

```

Prints **0** (falsy) for even, **1** (truthy) for odd. Try it online!

```
     « implicit integer input  »;
_2   « mod top of stack by 2   »;
     « implicit output         »;

```
> 0 votes

# Answer
# expr, 6 bytes

`$1 % 2`

Note expr(1) is a POSIX standard utility and is not a shell built in. It first arrived in UNIX V7.

Normal mod 2. Alternatively could have used a bitwise `&`
> 0 votes

# Answer
# ES2018, 8 Bytes

```
x=o=>o%2

```

Or, in ES5+typed arrays+intl:

# ES5, 25 Bytes

```
function x(o){return o%2}

```
> 0 votes

# Answer
# Brain-Flak, 10 bytes

```
({{}[{}]})

```

Try it online!

Takes input via unary. Odd corresponds to `1`, even to `0`. Basically alternates between adding and subtracting the unary values to a total until it runs out of numbers and pushes the total. If the number is odd, then there is an extra 1 and it returns 1.
> 0 votes

# Answer
# Momema, 13 bytes

```
z*-8 01z0-8*0

```

Try it online! Outputs `0` for odd, `1` for even.

## Explanation

Momema's control flow is in the form of named jumps, which also function as labels. Ungolfed, this program is:

```
z   *-8
0   1
z   0
-8  *0

```

Each jump instruction takes an argument `n` and evaluates it. Its semantics are "jump past `n` jump instructions from here, ignoring any that don't share my label and cyclically wrapping around the program as necessary if one is not found."

That last part—the cyclic wrapping—is important here. An even parameter will continue searching for jump instructions and finish on the first jump instruction, and an odd parameter will finish on the second jump instruction. In the first case, the assignment statement will fill cell `0` (initially with value `0`) with value `1`. After that, it encounters a jump instruction, but since the argument is `0`, it has no effect. Finally, in both cases, `-8` outputs the value of cell `0` in decimal, and its value will be set to `0` if and only if the input integer was even.

If outputting nothing for odd/something for even is allowed, the following program works for **10** bytes:

```
z*-8-8 1z0

```
> 0 votes

# Answer
# SmileBASIC, 13 bytes

```
INPUT N?N<<31

```

SB uses 32 bit integers, so shifting left by 31 places will preserve only the lowest bit. Even numbers become `0` (falsey), odds become `-2147483548` (truthy).

Works on both positive and negative numbers.
> 0 votes

# Answer
# ActionScript 2.0, 36 bytes

```
function a(b){trace(!Boolean(b%2));}
function a(b){                       - define a function taking one argument:
              trace(                 - output
                    !                - the opposite of
                     Boolean(        - the next bit converted to boolean:
                             b%2     - the function's argument mod 2
                                ));} - finish defining the function

```

a(2); traces 'true', a(3); traces 'false'

Note: it could probably be made smaller if it didn't matter what the output format was, but I think this is pretty small if it has to be a boolean, and you could obviously cut it down by one if you didn't mind true meaning odd and false meaning even.
> 0 votes

# Answer
# Charm, 11 bytes

```
[ 2 / pop ]

```

Try it online!
> 0 votes

# Answer
# C (gcc), ~~109~~ 99 bytes

```
#include <stdio.h>
void main(){int n;scanf("%d",&n);if(n&1)printf("%d:1",n);else printf("%d:0",n);}

```

Try it online!

C (gcc), 82 bytes : If we are only returning Integers 0 or 1 and not explicitly printing.

```
#include <stdio.h>
int main(){int n;scanf("%d",&n);if(n&1)return 0;else return 1;}

```

Try it online!

***EDIT***: Thanks @user202729 for your suggestions! They've been implemented and it cut a good 10 bytes off the code! Wasn't able to implement the printf() and scanf() functions without the #include statement so going to look some more into that. 0 now means True (or Odd in this case) and 1 now means False (or Even in this case).

**A brief explanation:**

Originally, I was going to use the printf() prototype instead of including stdio.h. However, the need for scanf() to take input ruined the C minimalism a bit. :)

First we initialize an integer "n", our number we're checking parity for. Then we scanf() for the user to enter the value of n. Since we are able to determine if a number is odd or even by determining if it's first bit (farthest to the right, lowest) is set or unset (1 or 0). In this case, a bit set to 1 means the number is odd, whereas a bit set to 0 means the number is even. The code checks for Odd (True), and else Even.
> 0 votes

# Answer
# C (gcc), 17

This does not require any headers. & is bitwise AND; it runs way faster than regular operators. Example: f(7)=\> 7 is 111 =\> 111 AND 1 is 1. If a number's last digit in base 2 is 0, it is even. Else, it is odd. And &1 runs way faster than %2.

```
f(i){return i&1;}

```
> 0 votes

# Answer
## Python REPL/Shell, 9 bytes

```
input()&1

```

returns 0 for even and 1 for odd
> 0 votes

# Answer
# HadesLang, 20 bytes

```
raw:[in:[]] % 2 is 0

```

`in:[]` Reads from console
`raw:[]` Converts a string to any required datatype
> 0 votes

# Answer
# Eukleides, 20 bytes

```
print number()mod 2

```

It's trivial, but at least Eukleides has an entry now. `number()` is the function to take a number as input, and you're supposed to pass it a string to use as a prompt. I thought for sure I'd had to actually pass an empty string before, but I'm not getting an error, so I'll take it. Since it's a simple `mod 2`, 1 means odd and 0 means even.
> 0 votes

# Answer
# JavaScript (Node.js), 6 bytes

Prints 0 for even, 1 for odd

```
a=>a&1

```

Try it online!
> 0 votes

# Answer
# Ahead, 5 bytes

```
I2%O@

```

1 == true == odd. 0 == false == even.

Try it online!
> 0 votes

# Answer
# Pepe, 14 bytes

```
rEeEreEEEEreEE

```

Try it online! (Fails in large cases like `99999999999999999`)

`0` for even, `1` for odd

Explanation:

```
rEeE           # input as int
    reEEEE     # ...mod 2
          reEE # output int

```
> 0 votes

# Answer
# Tamsin, 19 bytes

```
main={"0"&"0"}&eof.

```

Try it online!

Takes input in unary. Recognizes an even number of `0` characters.
> 0 votes

# Answer
# Gol\>\<\>, 5 bytes

```
I2%zh

```

take input, push 2, modulo a, b, then if the number was even, output 1, otherwise output 0

Try it online!
> 0 votes

# Answer
# BotEngine, 3x9=27 (27 bytes)

```
v  02468
>IRSSSSST
  F<<<<<

```

Outputs `TRUE` for odd and `FALSE` for even.
> 0 votes

# Answer
# Microscript, 4 bytes

```
2si%

```

# Microscript II, 4 bytes

```
2sN%

```

Prints `1` for odd and `0` for even.
> 0 votes

# Answer
# Pyramid Scheme, ~~185~~ 149 bytes

```
     ^
    /=\
   ^---^
  ^-  /#\
 ^-  ^---
/#\ /+\
---^---^
  /"\ ^-
 ^---/"\
 -^ ^---
 //\-
^---^
-^ /2\
/#\---
---^
  / \
 /arg\
^-----
-^
/1\
---

```

Try it online!

Uses a different method from Khuldraeseth's answer, and outputs `1` for odd numbers, `0` for even. This takes input as a command line argument. This basically equates to:

```
a = int(input())/2
print(a == int(str(a) + str(0)))

```

This works because a string like `"0.5"+"0"` is converted to the float `0.5`, whereas `"1"+"0"` will be `10`. This means numbers already with a decimal point will ignore the added `0`.
> 0 votes

# Answer
**Scala 8 bytes**

```
a=>a%2<1

```

Similar to the Java 8 solution and probably should also include type to compile like this:

```
 val m:Int=>Boolean=a=>a%2<1

```
> 0 votes

# Answer
# Underload, 10 bytes

```
(0)(1)()^S

```

Input is in hard-coded in Unary, using `~` in the 3rd bracket. `0` for odd, `1` for even.

Try it Online!
> 0 votes

# Answer
# AsciiDots, 16 bytes

```
.-#?{&}$#
 .-#1/

```

Outputs 0 if even, and 1 if odd. Basically just a Boolean AND with 1.

Try it online!
> 0 votes

# Answer
# asm2bf, 7 bytes

```
modr1,2

```

Yes, it compiles. Takes input in r1, writes output to r1. `1` for odd, `0` for even.
> 0 votes

# Answer
## SystemVerilog, 29 bytes

```
task t(n);$write(n%2);endtask

```

Prints `1` for odd numbers and `0` for even numbers.

Testbench:

```
module m;
  initial begin
    t(1);
    t(2);
    t(16384);
    t(99999999);
  end

  task t(n);$write(n%2);endtask
endmodule

```

Output (VCS on EDA Playground):

```
 1         0         0         1

```
> 0 votes

# Answer
# FEU, 21 bytes

```
u/x
m/^(xx)+x$/1/x+/0

```

Try it online!

0 for even, 1 for odd
> 0 votes

# Answer
# Python 3, 15 bytes

```
lambda n:n%2==0

```

Try it online!

Prints True/False when even/odd respectively.
> 0 votes

# Answer
# Rockstar, 47 bytes

```
listen to N
let D be N/2
turn up D
say D is N/2

```

Try it here (Code will need to be pasted in)
> 0 votes

# Answer
# 05AB1E, 1 Byte

```
É

```

Try it online!

```
   # (implicit) push STDIN to stack
É  # push 1 if top of stack is odd, 0 if even
   # (implicit) output top of stack to STDOUT

```
> 0 votes

# Answer
# Duocentehexaquinquagesimal, 6 bytes

```
5Q¬$††

```

Try it online!
> 0 votes

# Answer
# Python 3, 16 bytes

```
x=lambda n:n%2<1

```

Try it online!
> 0 votes

# Answer
# INTERCAL, 39 bytes

Domain is `ZERO` or `OH` to `FOUR TWO NINE FOUR NINE SIX SEVEN TWO NINE FIVE`. `_` (zero) for even and `I` (one) for odd. Also works in CLC-INTERCAL.

```
DOWRITEIN:1DO:1<-':1~#1'PLEASEREADOUT:1

```

Try it online!
> 0 votes

# Answer
# INTERCAL (C-INTERCAL), 229 bytes

This version accepts any integers, in decimal (e.g. `-156`); requires to be terminated with EOF.

Outputs `_` for even and `I` for odd.

```
DO,1<-#1DOCOMEFROM#3DOWRITEIN,1(1)DO.1<-,1SUB#1DO.2<-.4DO(1000)NEXTDO.4<-.3PLEASE.3<-!3~#15'$!3~#240'DO.3<-!3~#15'$!3~#240'DO.2<-!3~#15'$!3~#240'PLEASE.1<-.5DO(1010)NEXT(3)DO.5<-.2PLEASECOMEFROM.1~#256DO.2<-.2~#128PLEASEREADOUT.2

```

Try it online!

## How it works

* First part is taken from 229 bytes of cat program but without READing out character.
* In ASCII `0` is 48, `1` is 49, ... `9` is 57.
* But C-INTERCAL reverses bit order, so `0` is 0x0c, `1` is 0x8c, ... `9` is 0x9c.
* If bit at 0x80 is 1, then it's odd digit.
> 0 votes

# Answer
# Python REPL, 14 bytes

```
int(input())%2

```

Where `0` (falsy) is even, and `1` (truthy) is odd.
> 0 votes

# Answer
# LOLCODE, 151 bytes

```
HAI 1.2
I HAS A N
GIMMEH N
N IS NOW A NUMBAR
I HAS A V ITZ QUOSHUNT OF N AN 2
VISIBLE MAEK BOTH SAEM DIFF OF V AN MAEK V A NUMBR AN 0.5 A NUMBR
KTHXBYE

```

Try it online!
> 0 votes

# Answer
# Headascii, ~~20~~ 13 bytes

```
{UN()}:R--O<E

```

Try it here! Code will have to be copied and executed like this:

```
erun("{UN()}:R--O<E","input here")

```

Outputs two differing error messages. For odd inputs:

```
error 0:12 E [ 1, 0, 0, 1 ] (1)
'Error: E index out of range'

```

For even inputs:

```
error 0:12 E [ 1, 0, 0, 1 ] (2)
'Error: E index out of range'

```

Explanation:

```
{UN()}:R--O<E  Full program (Block 0)

{    }         Loop, which
 U             Discard(s) input byte(s)
  N() :        Until there is no input
  N(           (and stores 1 in the comparison register)
       R       Recall the last byte
        --O    Subtract 2 and save
           <   If this number is less than the comparison register (1)
                 Return the number in the comparison register (1)
               Else
                 Return 0
            E  Go to the code block corresponding to this number.
               If it is block 0, the program loops to the beginning
               with the saved byte as "input"
               If it is block 1, the program will exit with an error,
               as there is no block 1 in this program. The error message
               will include register state information, including the
               currently recall-able byte. In this state of the program,
               odd inputs will have reached 1, and even inputs will have
               reached 2.

```

I still think this is further golfable, but I'm proud of this clever little -7

#### Old solution (20 bytes):

```
{UN)}:R--O(<)[E:+()?

```

Try it here! Code will have to be copied and executed like this:

```
erun("{UN)}:R--O(<)[E:+()?","input here")

```

Prints a Headascii debug message if odd, and nothing if even.

Explanation:

```
{UN)}:R--O(<)[E:+()?  Full program

{   }                 Loop which
 U                    Discard(s) input byte(s)
  N) :                Until there is no more input
      R               Recall the last byte (as a number)
       --O            Subtract 2 and save
          (<)         If the number is greater than or equal to 0
             [E         Return to start of program, with saved number as input
               :      Else
                +()     If the number is -1
                   ?      Print a debug message

```

Repeatedly subtracts 2 from the last digit until it is -1 or -2. There might be a way to shave off a byte or two by switching the conditions / thens / elses around a bit. Just want to submit for now
> 0 votes

# Answer
# GolFunc, 9 bytes

```
.O..%.JN2

```

Outputs `1` for odd inputs and `0` for even inputs. (there will soon be an interpreter, but this works for now)

Explanation:

```
     .JN  # take input as a number
  ..%   2 # mod 2
.O        # and then output.

```
> 0 votes

# Answer
# minigolf, 6 bytes

```
0i,0=_

```

Attempt This Online!

## Explanation

```
0      0, Initial output: 0 _
i,     0, Repeat input times: _
  0=   0, Logical not (is it equal to 0?) _
_      0, End repeat _

0, Implicit output TOS _

```
> 0 votes

# Answer
# Desmoslang, 10 Bytes

```
\mod(I,2OT

```

0 means even, 1 means odd.
> 0 votes

# Answer
# sed, 20 bytes

```
s/^(!!)*$/T/
s/!+/F/

```

Try it online!

Input is in Unary, using exclamation marks.
> 0 votes

# Answer
# Javascript \<= ES5, 28 bytes

```
function i(n){return n%2==1}

```

If returning `1` or `0` is allowed, than (27 bytes):

```
function i(n){return n%2&1}

```
> -2 votes

---
Tags: code-golf, arithmetic, number-theory, decision-problem
---