> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/e/even_or_odd.md).

# Even or odd

Built-in methods:

```ruby
var n = 42;
say n.is_odd;       # false
say n.is_even;      # true
```

Checking the last significant digit:

```ruby
func is_odd(n)  { n&1 == 1 };
func is_even(n) { n&1 == 0 };
```

Using modular congruences:

```ruby
func is_odd(n)  { n%2 == 1 };
func is_even(n) { n%2 == 0 };
```
