Skip to content

IsOdd ​

Whether n is an odd integer.

✓ checked against that system · ! checked, with disagreements (hover a chip)Fungrim entry1c376628b4c364f0a5c0e088✓fd732d✓Wolfram LanguageOddQ!
IsOdd(n)TrueTrue if nn is an odd integer, else FalseFalse.
Juliais_odd(ZZ(n))Rustis_odd(n)
Typed signatures
TypePackageApplies
(number) -> booleananalyticreplaces compute-enginealways
(number) -> booleancompute-enginealways

Domain: Arithmetic

Examples

Basic #
live ↗
InIsOdd(3)\mathrm{IsOdd}(3)OutTrue\mathrm{True}
live ↗
InIsOdd(4)\mathrm{IsOdd}(4)OutFalse\mathrm{False}

Negative integers count too

live ↗
InIsOdd(−7)\mathrm{IsOdd}(-7)OutTrue\mathrm{True}
live ↗
InIsOdd(0)\mathrm{IsOdd}(0)OutFalse\mathrm{False}

9 is odd

live ↗
InIsOdd(9)\mathrm{IsOdd}(9)OutTrue\mathrm{True}
Scope #

A non-integer is not odd

live ↗
InIsOdd(3.5)\mathrm{IsOdd}(3.5)OutFalse\mathrm{False}
live ↗
InIsOdd(13)\mathrm{IsOdd}(\frac{1}{3})OutFalse\mathrm{False}

Big integers

live ↗
InIsOdd(2100+1)\mathrm{IsOdd}(2^{100}+1)OutTrue\mathrm{True}

π\pi is known not to be an integer, so it is decided False

live ↗
InIsOdd(π)\mathrm{IsOdd}(π)OutFalse\mathrm{False}

Threads element-wise over a list

live ↗
InIsOdd([1,2,3])\mathrm{IsOdd}(\bigl\lbrack1, 2, 3\bigr\rbrack)Out[True,False,True]\bigl\lbrack\mathrm{True}, \mathrm{False}, \mathrm{True}\bigr\rbrack
Applications #

Select the odd numbers up to 10

live ↗
InFilter(1..10,IsOdd)\mathrm{Filter}(1..10, \mathrm{IsOdd})Out[1,3,5,7,9]\bigl\lbrack1, 3, 5, 7, 9\bigr\rbrack

True if every entry is odd

live ↗
InIsVector([1,5,7,11],IsOdd)\mathrm{IsVector}(\bigl\lbrack1, 5, 7, 11\bigr\rbrack, \mathrm{IsOdd})OutTrue\mathrm{True}

False because the first entry is even

live ↗
InIsVector([2,5,7,11],IsOdd)\mathrm{IsVector}(\bigl\lbrack2, 5, 7, 11\bigr\rbrack, \mathrm{IsOdd})OutFalse\mathrm{False}
Properties #

An integer is odd exactly when it is not even. See IsEven

live ↗
InIsOdd(7)=¬IsEven(7)\mathrm{IsOdd}(7)=¬\mathrm{IsEven}(7)OutTrue\mathrm{True}

2 is even, hence not odd

live ↗
InIsOdd(2)\mathrm{IsOdd}(2)OutFalse\mathrm{False}

15 is odd

live ↗
InIsOdd(15)\mathrm{IsOdd}(15)OutTrue\mathrm{True}
Possible issues #

A symbol stays undecided rather than False

live ↗
InIsOdd(x)\mathrm{IsOdd}(x)OutIsOdd(x)\mathrm{IsOdd}(x)
About
Examples17
Checked againstWolfram Language 16 agree1 differSymPy 13 agree1 differJulia 9 agree3 errorRust 9 agree3 error
CrosswalkFungrim entry ×5Wolfram LanguageJuliaRust

Implementation

mappedsympypackages/oracle/src/mappings.ts

Wolfram's OddQ is False unless the operand is an odd integer, so SymPy's undecided is_odd (None), as for a symbol or 4.0, reads as False.

mappedjuliapackages/oracle/src/mappings.ts
mappedrustpackages/oracle/src/mappings.ts

See also: IsEven