https://www.codewars.com/kata/55cbc3586671f6aa070000fb
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:
This function should test if the factor is a factor of base.
Return true if it is a factor or false if it is not.
About factors
Factors are numbers you can multiply together to get another number.
2 and 3 are factors of 6 because: 2 * 3 = 6
- You can find a factor by dividing numbers. If the remainder is 0 then the number is a factor.
- You can use the mod operator (%) in most languages to check for a remainder
For example 2 is not a factor of 7 because: 7 % 2 = 1
Note: base is a non-negative number, factor is a positive number.
코드
function checkForFactor (base, factor) {
return base % factor === 0;
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] Small enough? - Beginner (7 kyu) / JavaScript (0) | 2023.03.08 |
---|---|
[Codewars] Bin to Decimal (8 kyu) / JavaScript (0) | 2023.03.07 |
[Codewars] Is it even? (8 kyu) / JavaScript (0) | 2023.03.05 |
[Codewars] Round up to the next multiple of 5 (7 kyu) / JavaScript (0) | 2023.03.04 |
[Codewars] You Can't Code Under Pressure #1 (8 kyu) / JavaScript (0) | 2023.03.04 |
댓글