9 lines
144 B
Text
9 lines
144 B
Text
// Using the modulo operator
|
|
even: func (n: Int) -> Bool {
|
|
(n % 2) == 0
|
|
}
|
|
|
|
// Using bitwise and
|
|
odd: func (n: Int) -> Bool {
|
|
(n & 1) == 1
|
|
}
|