Problem 56283. Determine if Input is Oddish or Evenish (Odd/Even Sum of Digits)
Given a positive integer n, determine whether n is "oddish" or "evenish" - that is, whether the sum of the digits of n is odd or even. Return 1 for odd(ish), 2 for even(ish).
oe = oddorevendigitsum(34093)
oe =
1
oe = oddorevendigitsum(39482)
oe =
2
In the first example, 3+4+0+9+3 = 19, which is odd. In the second, 3+9+4+8+2 = 26, which is even.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers298
Suggested Problems
-
Calculate the Levenshtein distance between two strings
1425 Solvers
-
Given an unsigned integer x, find the largest y by rearranging the bits in x
1822 Solvers
-
Fix the last element of a cell array
1342 Solvers
-
309 Solvers
-
641 Solvers
More from this Author22
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!