[DSA in Python] is_multiple.py

This was the first exercise of Chapter 1 (Python Primer) in the book 'Data Structures and Algorithms in Python' by Goodrich et al.

Problem: "Write a short Python function, is_multiple(n, m), that takes two integer values and returns True if n is a multiple of m, that is, n = mi for some integer i, and False otherwise."

There are some different variations of creating this function, but it boils down to checking on whether an operation behaves in a certain way.

The function will return the truthness or falseness of m % n == 0. If m % n is equal to 0, then we know that m is divisible by n. This means that m must also be a multiple of n.

  • The % is a modulo operator, which returns the remainder that occurs from the division of m / n.
  • By divisibility,  a number divided by another number must not leave a remainder.