Skip to content

Commit

Permalink
Add Even Odd in V (#4089)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaamkiya authored Dec 15, 2024
1 parent ecf63b8 commit 4a64fc4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions archive/v/v/even-odd.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module main

import os
import strconv

fn main() {
if os.args.len < 2 {
println('Usage: please input a number')
exit(1)
}

num := strconv.atoi(os.args[1]) or {
println('Usage: please input a number')
exit(1)
}

print(match num % 2 {
0 { 'Even' }
1, -1 { 'Odd' }
else { 'Usage: please input a number' }
})
}

0 comments on commit 4a64fc4

Please sign in to comment.