Skip to content

Latest commit

 

History

History
58 lines (33 loc) · 863 Bytes

Very_Even_Numbers.md

File metadata and controls

58 lines (33 loc) · 863 Bytes

CodeWars Python Solutions


"Very Even" Numbers.

Task

Write a function that returns true if the number is a "Very Even" number.

If the number is odd, it is not a "Very Even" number.

If the number is even, return whether the sum of the digits is a "Very Even" number.

Examples

input(88) => returns false -> 8 + 8 = 16 -> 1 + 6 = 7 => 7 is odd
input(222) => returns true
input(5) => returns false

Given Code

def is_very_even_number(n):
    return True

Solution 1

def is_very_even_number(n):
    return sum(map(int, str(n))) % 2 == 0 if n <= 10 else is_very_even_number(sum(map(int, str(n))))

Solution 2

def is_very_even_number(n):
    return (n - 1) % 9 % 2 != 0

See on CodeWars.com