https://www.codewars.com/kata/5545f109004975ea66000086
Codewars - Achieve mastery through coding practice and developer mentorship
A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!
www.codewars.com
DESCRIPTION:
Create a function that checks if a number n is divisible by two numbers x AND y. All inputs are positive, non-zero numbers.
Examples:
1) n = 3, x = 1, y = 3 => true because 3 is divisible by 1 and 3
2) n = 12, x = 2, y = 6 => true because 12 is divisible by 2 and 6
3) n = 100, x = 5, y = 3 => false because 100 is not divisible by 3
4) n = 12, x = 7, y = 5 => false because 12 is neither divisible by 7 nor 5
설명:
숫자 n이 x 그리고 y 두 숫자로 나누어지는지 확인하는 함수를 작성하세요. 모든 입력은 0이 아닌 양수입니다.
Examples:
1) n = 3, x = 1, y = 3 => true because 3 is divisible by 1 and 3
2) n = 12, x = 2, y = 6 => true because 12 is divisible by 2 and 6
3) n = 100, x = 5, y = 3 => false because 100 is not divisible by 3
4) n = 12, x = 7, y = 5 => false because 12 is neither divisible by 7 nor 5
풀이
n을 x로 나눈 나머지가 0이고 n을 y로 나눈 나머지가 모두 참이면 true를 그렇지 않다면 false를 반환했다.
코드
function isDivisible(n, x, y) {
return n % x === 0 && n % y === 0;
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] String ends with? (7 kyu) / JavaScript (1) | 2023.01.02 |
---|---|
[Codewars] Moving Zeros To The End (5 kyu) / JavaScript (0) | 2022.12.31 |
[Codewars] Keep Hydrated! (8 kyu) / JavaScript (0) | 2022.12.29 |
[Codewars] Ones and Zeros (7 kyu) / JavaScript (0) | 2022.12.28 |
[Codewars] Abbreviate a Two Word Name (8 kyu) / JavaScript (0) | 2022.12.27 |
댓글