Checking whether array elements can be made equal


Given an array a, write a function to feed in the array elements and check whether they can all be made equal by only multiplying the numbers by 2 or 7. (you can multiply by these #s as many times as you like)

If all elements can be made equal, return False, otherwise return True.


a = [128, 4, 2]

#Here, we can turn all elements into 128, by multiplying by 2
#128, 4*2*2*2*2*2 = 128, 2*2*2*2*2*2*2 = 128


a = [65, 4, 2]
#Here, we cannot make all elements equal through multiplication by 2 or 7, 
#so we return false



Access restricted

Subscribe to premium account to see the solution.

Get premium now