一个自然数倒过来读仍是这个数,就叫回文数,有些回文数还是素数,就叫回文式素数,如93239.以下程序用于请补充完善程序.Function hw(m As Long) As Boolean Dim a As Integer, b As Integer, c As Integer, d As Inte
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/23 12:34:41
一个自然数倒过来读仍是这个数,就叫回文数,有些回文数还是素数,就叫回文式素数,如93239.以下程序用于请补充完善程序.Function hw(m As Long) As Boolean Dim a As Integer, b As Integer, c As Integer, d As Inte
一个自然数倒过来读仍是这个数,就叫回文数,有些回文数还是素数,就叫回文式素数,如93239.以下程序用于
请补充完善程序.
Function hw(m As Long) As Boolean
Dim a As Integer, b As Integer, c As Integer, d As Integer
a = Left(m, 1): b = Mid(m, 2, 1)
c = _____________________
d = _____________________
hw = IIf(a = d And b = c, True, False)
End Function
Function ss(m As Long) As Boolean
Dim k As Long, i As Long, f As Boolean
f=True
k = Sqr(m)
For i = 2 To k
If _____________________ Then
f = False
Exit For
End If
Next i
________________
End Function
Private Sub Command1_Click()
Dim m As Long, n As Integer
For m = 10000 To 99999
If _____________________________ Then
Print Tab((n Mod 10) * 8 + 1); m;
n = n + 1
End If
Next m
End Sub
Mid(m,4,1) Right(m,1) 注意:只要能取出第四、五位即可得分
m mod i=0(只要能判断整除即可)
ss=f ss(m) hw(m)(只写ss及hw不得分,如果写了True但写错了扣1分)
一个自然数倒过来读仍是这个数,就叫回文数,有些回文数还是素数,就叫回文式素数,如93239.以下程序用于请补充完善程序.Function hw(m As Long) As Boolean Dim a As Integer, b As Integer, c As Integer, d As Inte
从m到n 间的回文素数
dim m,n,p,l,y,j,k as integer
dim a(100) as integer
FOR j = m TO n
p = 0
FOR k = 2 TO INT(SQR(j))
IF j / k = j \ k THEN p = 1
NEXT k
IF j = 1 THEN p = 1
IF p = 0 THEN
y = j
l = 0
DO
l = l + 1
a(l) = y MOD 10
y = y \ 10
LOOP WHILE y > 0
FOR k = 1 TO l \ 2
IF a(k) a(l + 1 - k) THEN p = 1
NEXT k
IF p = 0 THEN msgbox(j)
END IF
NEXT j