回 帖 发 新 帖 刷新版面

主题:一个问题谁能帮我解决

怎么算最小公倍数?
[em10][em10][em10]

回复列表 (共10个回复)

沙发

作者:moz
专家分:11550
 
 会员信息
 发短消息  
 所属BLOG  
 发表时间:2006-12-6 16:15:00    [修改]  [回复]  [引用] 
2 楼  
deflng a-z
function GongBei(a,b)
if a>b then swap a,b
for i=a to a*b step a
    if i mod b =0 then exit for
next
GongBei=i
end function

板凳

能不能加点分析。[em12][em11]

3 楼

DECLARE  SUB bei(x,y,z)
Cls
Input a,b,c
Call bei(a,b,c)
End

Sub bei(x,y,z)
 For I=x to x*y*z
  If I mod x=0 and I mod y=0 and I mod z=0 then ?I:end
 Next I
End sub

4 楼

在下谢谢各位了

5 楼

那怎么做最小公约数?
[em8][em8][em8]

6 楼

不用做,最小公约数铁定是1

7 楼

(弄错了)
应该是最大公因数怎么做?[em12]

8 楼

ab公因=(a+b)\ab公约
一个是另一个的倍数时要取小数为公约,大数为公因(非常重要的一句)

9 楼

deflng a-z
function GongEn(a,b)
if a>b then swap a,b
for i=1 to a
    if a mod i =0 then if b mod (a\i)=0 then exit for
next
GongEn=a\i
end function

听说还有一个方法叫做反复取余法,我不太记得了.看对不对?

deflng a-z
function GongEn(a,b)
if a>b then swap a,b
do while b mod a
  b=b mod a
  swap a,b
loop
GongEn=a
end function

10 楼

辗转相除吧

我来回复

您尚未登录,请登录后再回复。点此登录或注册