## Blog Pages

### Check wheather a number is composite or not

```#Credits to NPTEL MOOC, Programming, Data Structures & Algorithms in
#Python by Madhavan Mukund, Chennai Mathematical Institute ```
` `
```def composite(n):
for i in range(2,n):
if n%i == 0:
return(True)
return(False)```

### Divison with multiple conditions

```#Credits to NPTEL MOOC, Programming, Data Structures & Algorithms in
#Python by Madhavan Mukund, Chennai Mathematical Institute ```

def divides(m,n):
if n%m == 0:
return(True)
else:
return(False)

def even(n):
return(divides(2,n))

def odd(n):
return(not divides(2,n))

### GCD using euclids algorithms & looping

# Credits to NPTEL MOOC,Programming, Data Structures & Algorithms
#in Python by Madhavan Mukund, Chennai Mathematical Institute

def gcd(m,n):
if m < n:  # Assume m >= n
(m,n) = (n,m)
while (m%n) != 0:
diff = m-n
# diff > n? Possible!
(m,n) = (max(n,diff),min(n,diff))
return(n)

### Greatest common divisor program using euclids algorithms

```#Credits to NPTEL MOOC, Programming, Data Structures & Algorithms in
#Python by Madhavan Mukund, Chennai Mathematical Institute ```
` `
def gcd(m,n):
if m < n:
(m,n) = (n,m)
if (m%n) == 0:
return(n)
else:
diff = m-n
return(gcd(max(n,diff),min(n,diff)))

print(gcd(12,3))

### Greatest common divisor program with looping

```#Credits to NPTEL MOOC, Programming, Data Structures & Algorithms in
#Python by Madhavan Mukund, Chennai Mathematical Institute ```

def gcd(m,n):
i = min(m,n)
while i > 0:
if (m%i) == 0 and (n%i) == 0:
return(i)
else:
i = i-1