小说网 找小说 无限小说 烟雨红尘 幻想小说 酷文学 深夜书屋

最小公倍数

“辗转相除法”求解最小公倍数 Function LCM(ParamArray nums()) As Long Dim temp1 As Long, temp2 As Long, I As Long LCM = nums(0) For I = 1 To UBound(nums) temp1 = LCM temp2 = nums(I) LCM = LCM * temp2 Do If temp1 < temp2 Then temp = temp1 temp1 = temp2 temp2 = temp End If temp1 = temp1 Mod temp2 Loop While temp1 LCM = LCM / temp2 Next End Function '调用: MsgBox LCM(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

posted on 2007-04-08 14:52  王峰炬  阅读(124)  评论(0编辑  收藏  举报

导航