Skip to content

Instantly share code, notes, and snippets.

@arakban
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arakban/9119672 to your computer and use it in GitHub Desktop.
Save arakban/9119672 to your computer and use it in GitHub Desktop.
This piece of code the multiples of the numbers a and b, from 0 to the number set as the limit by the user.
def multiples(limit,a,b):
n = 0
while n<limit:
if n%a == 0 and n%b == 0:
print str(n) + ' is a multiple of ' + str(a) + ' and ' + str(b)
n = n + 1
elif n % a == 0:
print str(n) + ' is a multiple of ' + str(a)
n = n + 1
elif n % b == 0:
print str(n) + ' is a multiple of ' + str(b)
n = n + 1
else:
n = n + 1
return 'Finding the multiples is over guys!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment