加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

vb.net – 检查数字是否可以被另一个数字整除的快速方法?

发布时间:2020-12-17 00:19:44 所属栏目:大数据 来源:网络整理
导读:我想知道在VB.NET中检查可分性的最快方法是什么. 我尝试了以下两个功能,但我觉得好像有更有效的技术. Function isDivisible(x As Integer,d As Integer) As Boolean Return Math.floor(x / d) = x / dEnd Function 我想出的另一个: Function isDivisible(x
我想知道在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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读