finding the LCM using python
<p>def multiple(a, b):
    """so I'm trying to return the smallest number n that is a multiple of both a and b.</p>

<p>for example:</p>

<blockquote>
  <blockquote>
    <blockquote>
      <p>multiple(3, 4)
          12
      multiple(14, 21)
          42
          """</p>
    </blockquote>
  </blockquote>
</blockquote>

<pre><code>def gcd (a,b):
    if a &lt; b : a , b = b,a
    while b:
        a , b = b , a % b
    return a

def lcm (a , b):
    n= (a*b) / gcd(a,b)
    return n
</code></pre>

<p>it keeps throwing errors about indentation and logic. I don't understand why. I've tried changing the variables around too.</p>

<p>No need to find GCD, we can directly find LCM. Below code works</p>

<pre><code>def lcmof(x,y):
    res=0
    mx=max(x,y)
    mn=min(x,y)
    for i in range(1,mx+1,1):
        temp=mx*i
        try:
            if(temp%mn==0):
                res=temp
                break
        except ZeroDivisionError:
            res=0
            break
    return res
</code></pre>

python lcm