Very Simple, beats 100%, Java, Bit Manipulation
Intuition\n Describe your first thoughts on how to solve this problem. \nThe question asks for the smallest even multiple of a number and 2. Any even number wil
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe question asks for the smallest even multiple of a number and 2. Any even number will be a multiple of 2. So we only care about the other number, if the number is even, return the number. Else, the number can only be odd. To make this odd number into even we can either add a odd number (1, 3, 5...). To get the smallest even which is divisble by the number we have to add the number itself(which will be odd) or just multiply it by 2.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nI am checking if the n is odd and returning 2n otherwise n.\nThe method to check if a number is odd is => (N & 1) == 1. Why this works is because of bit manipulation. Any odd number will have 1 in the end in its binary representation or at it least significant bit. \nTaking AND of any number with 1 tells us whetehr the number is odd or even.\nlets check for a few numbers :\n1 => 1 & 1 = 0001 & 0001 = 0001 => 1(odd)\n2 => 2 & 1 = 0010 & 0001 = 0000 => 0(even)\n3 => 3 & 1 = 0011 & 0001 = 0001 => 1(odd)\n5 => 5 & 1 = 0101 & 0001 = 0001 => 1(odd)\n8 => 8 & 1 = 1000 & 0001 = 0000 => 0(even)\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(1)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\no(1)\n\n# Code\n```\nclass Solution {\n    public int smallestEvenMultiple(int n) {\n        return ((n&1) == 1) ? (n*2) : (n);\n    }\n}\n```
['Math', 'Bit Manipulation', 'Java']