我想知道在VB.NET中检查可分性的最快方法是什么.
我尝试了以下两个功能,但我觉得好像有更有效的技术.
Function isDivisible(x As Integer,d As Integer) As Boolean Return Math.floor(x / d) = x / d End Function
我想出的另一个:
Function isDivisible(x As Integer,d As Integer) As Boolean Dim v = x / d Dim w As Integer = v Return v = w End Function
这是一种更实用的方法吗?
使用Mod:
Function isDivisible(x As Integer,d As Integer) As Boolean Return (x Mod d) = 0 End Function