Files
30-seconds-of-code/snippets/is_divisible.md
2021-01-04 12:47:04 +02:00

327 B

title, tags, unlisted
title tags unlisted
is_divisible math,beginner true

Checks if the first numeric argument is divisible by the second one.

  • Use the modulo operator (%) to check if the remainder is equal to 0.
def is_divisible(dividend, divisor):
  return dividend % divisor == 0
is_divisible(6, 3) # True