Codewars note:Can we divide it ?

My Codewars

 exercise:

Your task is to create the functionisDivideBy (or is_divide_by) to check if an integer number is divisible by both integers a and b.

A few cases:

(-12, 2, -6)  ->  true
(-12, 2, -5)  ->  false

(45, 1, 6)    ->  false
(45, 5, 15)   ->  true

(4, 1, 4)     ->  true
(15, -5, 3)   ->  true

Solution:
def is_divide_by(number, a, b):
    return number % a & number % b is 0

 

posted @ 2022-07-03 12:20  大序列  阅读(10)  评论(0编辑  收藏  举报