Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
14
Task/Even-or-odd/Nim/even-or-odd.nim
Normal file
14
Task/Even-or-odd/Nim/even-or-odd.nim
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Least signficant bit:
|
||||
proc isOdd(i: int): bool = (i and 1) != 0
|
||||
proc isEven(i: int): bool = (i and 1) == 0
|
||||
|
||||
# Modulo:
|
||||
proc isOdd2(i: int): bool = (i mod 2) != 0
|
||||
proc isEven2(i: int): bool = (i mod 2) == 0
|
||||
|
||||
# Bit Shifting:
|
||||
proc isOdd3(n: int): bool = n != ((n shr 1) shl 1)
|
||||
proc isEven3(n: int): bool = n == ((n shr 1) shl 1)
|
||||
|
||||
echo isEven(1)
|
||||
echo isOdd2(5)
|
||||
Loading…
Add table
Add a link
Reference in a new issue