Programmers Scala Study (level 1.27)

27. 짝수와 홀수

문제 설명

짝수인지 홀수인지 확인

Inputs

Variable Name type meaning
num Int target num

output

return String // Even or Odd

Conditions

  • num
    • in range of Integer
    • 0 is even

Test cases

num return
3 “Odd”
4 “Even”

Solution

def solution(num: Int): String = {
  if (num%2 == 0) "Even" else "Odd"
}

Study from Implementation