DEV Community

SalahElhossiny
SalahElhossiny

Posted on

Smallest Even Multiple

Given a positive integer n, return the smallest positive integer that is a multiple of both 2 and n.


class Solution(object):
    def smallestEvenMultiple(self, n):
        """
        :type n: int
        :rtype: int
        """
        res = 2 
        while True:
            if res % n == 0:
                return res
            res += 2






Enter fullscreen mode Exit fullscreen mode

Top comments (0)