麻烦帮忙做几道vb编程题,请用if函数做!
1.求1到2000之间的双胞胎数的对数。双胞胎数:两素数差微微2称为双胞胎数。例如227和229是一对双胞胎数,它们都是素数且差为2.答案:612.求200到3000中所...
1.求1到2000之间的双胞胎数的对数。双胞胎数:两素数差微微2称为双胞胎数。例如227和229是一对双胞胎数,它们都是素数且差为2.答案:61
2.求200到3000中所有回文数的和,回文数师正读和反读都是一样的数,如525,1551. 答案:87970
3.计算Y=X/1!-X^3/3!+X^5/5!-X^/7!+……前20项的值(已知:X=2)
4.若某正整数平方等与某两个正整数平方之和,称该正整数为弦数。例:3^2+4^2=5^2,则5 为弦数,求【131,200】之间最小的弦数。答案:135
5已知X,Y,Z为三个正整数,且X^2+Y^2+Z^2=25^2,求X+Y+Z的最大值。答案:43 展开
2.求200到3000中所有回文数的和,回文数师正读和反读都是一样的数,如525,1551. 答案:87970
3.计算Y=X/1!-X^3/3!+X^5/5!-X^/7!+……前20项的值(已知:X=2)
4.若某正整数平方等与某两个正整数平方之和,称该正整数为弦数。例:3^2+4^2=5^2,则5 为弦数,求【131,200】之间最小的弦数。答案:135
5已知X,Y,Z为三个正整数,且X^2+Y^2+Z^2=25^2,求X+Y+Z的最大值。答案:43 展开
2个回答
展开全部
1。是61
Private Sub Command1_Click()
Dim num As Integer
Dim j As Long
For j = 2 To 2000
If Zhishu(j) And Zhishu(j + 2) Then
num = num + 1
End If
Next
Print num
End Sub
Private Function Zhishu(ll As Long) As Boolean
Dim i As Long
Zhishu = True
For i = 2 To Sqr(ll)
If ll Mod i = 0 Then
Zhishu = False
Exit For
End If
Next
End Function
Private Sub Command1_Click()
Dim num As Integer
Dim j As Long
For j = 2 To 2000
If Zhishu(j) And Zhishu(j + 2) Then
num = num + 1
End If
Next
Print num
End Sub
Private Function Zhishu(ll As Long) As Boolean
Dim i As Long
Zhishu = True
For i = 2 To Sqr(ll)
If ll Mod i = 0 Then
Zhishu = False
Exit For
End If
Next
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询