Skip to content

Latest commit

 

History

History
31 lines (19 loc) · 846 Bytes

is-divisible.md

File metadata and controls

31 lines (19 loc) · 846 Bytes
标题 标签
isDivisible(是否可被整除) math(数学)

检查第一个数字参数是否可以被第二个整除。

  • 使用模运算符 (%) 检查余数是否等于 0。
const isDivisible = (dividend, divisor) => dividend % divisor === 0;

ts 代码如下:

调用方式:

isDivisible(6, 3); // true

应用场景

以下是一个实战示例:

结果如下:

<iframe src="codes/javascript/html/is-divisible.html"></iframe>