Python Clean solution


#1

class Solution:
# @param A : integer
# @param B : integer
# @param C : integer
# @param D : integer
# @return an integer
def solve(self, a, b, c, d):

    def gcd(a,b): 
        if a == 0: 
            return b 
        return gcd(b % a, a) 

    def lcm(a,b): 
        return (a*b) / gcd(a,b) 
    
    if a==1 or b==1 or c==1:
        ans=d-1
    else:
        x=lcm(a,b)
        y=lcm(a,c)
        z=lcm(b,c)
        d=d-1
        ans=d//a + d//b +d//c - d//x - d//y - d//z
    return ans