DEV Community

SalahElhossiny
SalahElhossiny

Posted on

1 1

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)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay