两个合数是素数,它们的最小公倍数是260,求两个数.
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 12:57:57
两个合数是素数,它们的最小公倍数是260,求两个数.
两个合数是素数,它们的最小公倍数是260,求两个数.
两个合数是素数,它们的最小公倍数是260,求两个数.
楼上说错了
20+13=33不是素数啊,不满足楼主说的条件
不过我用VB模拟了一下,就诶过仍然算不出楼主的谜底.
话说真的有这样的数字吗?是不是楼主条件错了?
下面是我的代码:
Option Base 1
Dim counter As Long
Dim a() As Long
Private Sub Command1_Click()
Dim x As Long
Dim y As Long
counter = 0
For var = 1 To 260
got var
Next var
Print counter
For x = 1 To counter
For y = 1 To counter
If a(x) > a(y) Then
If a(x) * a(y) / 260 = MOD_(a(x),a(y)) Then
Text1.Text = Text1.Text & a(x) & "—" & a(y) & Chr(13) & Chr(10)
If pan(a(x) + a(y)) Then
Text2.Text = Text2.Text & a(x) & "—" & a(y) & Chr(13) & Chr(10)
End If
End If
Else
If a(x) * a(y) / 260 = MOD_(a(y),a(x)) Then
Text1.Text = Text1.Text & a(x) & "—" & a(y) & Chr(13) & Chr(10)
If pan(a(x) + a(y)) Then
Text2.Text = Text2.Text & a(x) & "—" & a(y) & Chr(13) & Chr(10)
End If
End If
End If
Next y
Next x
End Sub
Function MOD_(ByVal x As Long,ByVal y As Long) As Long
Do
t = x Mod y
x = y
y = t
Loop While t 0
MOD_ = x
End Function
Private Sub got(ByVal var As Long)
flag = 0
For i = 2 To Int(Sqr(var))
If var Mod i = 0 Then
flag = flag + 1
End If
Next i
If flag > 0 Then
counter = counter + 1
ReDim Preserve a(counter)
a(counter) = var
End If
End Sub
Function pan(ByVal var As Long) As Boolean
flag = 0
For i = 2 To Int(Sqr(var))
If var Mod i = 0 Then
flag = flag + 1
End If
Next i
If flag = 0 Then
pan = True
Else
pan = False
End If
End Function
代码是没有错误的,我已经试验很多次了.
如果我错了,烦请楼主知道答案时告诉我一声.