Create a function isDivisible(n, x, y)
that checks if a number n
is divisible by two numbers x
AND y
. All inputs are positive, non-zero digits.
Example:
is_divisible(3,1,3)--> True because 3 is divisible by 1 and 3
is_divisible(12,2,6)--> True because 12 is divisible by 2 and 6
is_divisible(100,5,3)--> False because 100 is not divisible by 3
is_divisible(12,7,5)--> False because 12 is neither divisible by 7 nor 5
This challenge comes from naaz on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!
Top comments (10)
Ruby
Trick question. In the instructions, it says to make a function called isDivisible() but in the example, it uses is_divisible() 🤔
PHP:
JavaScript
ruby
No, Bro, it's not working.
Haskell
Test.
No bro it's not working
Failed to detect module name:
isDivisibleBy :: Int -> Int -> Int -> Bool
isDivisibleBy x y n = all ((==) 0 . mod n) [x, y]
Hi and thanks for your comment.
Have you tried the test link?
Racket
No, it's not working.
default-load-handler: expected a `module' declaration, but found something else
file: /workspace/racket/solution.rkt
context...:
default-load-handler
standard-module-name-resolver
perform-require!78
for-loop
finish
[repeats 1 more time]
pass-1-and-2-loop
module-begin-k
expand-module16
expand-capturing-lifts
temp118_0
temp91_0
compile15
temp85_0
standard-module-name-resolver
module-path-index-resolve
...
Some comments may only be visible to logged-in visitors. Sign in to view all comments.