?一个数如果刚好与它的因子之和相等,则称完数。求5到100间的完数之和,
结果:34
Sum = 0
For n = 5 To 100
s = 0
For i = 1 To n - 1
If n Mod i = 0 Then s = s + i
Next i
If s = n Then Sum = Sum + n
Next n
Print Sum
?ijk+kji=1333,其中i,j,k的范围是0到9,求有几组(i,j,k)满足条件,结果:6
c = 0
For i = 0 To 9
For j = 0 To 9
For k = 0 To 9
If i * 100 + j * 10 + k + k * 100 + j * 10 + i = 1333 Then c = c + 1
Next k, j, i
Print c
?宴会上共有1225次握手,每一位参加的人对其他的人都有同样的礼节,那么与会人士有多少,结果:50
人数握手数
1 0
2 1
3 3
4 6
n个人的握手数为:1+2+3+。。。+n-1=1225,解得n=50
?司机开车时里程表读数为一回文数12321公里,开了2小时后里程表又是一个最小回文数,求司机的开车速度。结果:50
下一个最小回文数肯定是12421,(12421-12321)/2=50
n = 12321
Do
n = n + 1
a = n \ 10000
b = n \ 1000 Mod 10
c = (n Mod 100) \ 10
d = n Mod 10
Loop While a <> d Or b <> c
Print (n - 12321) / 2
?
好啊好
+ 真的好
-------------------
真的好啊
如果是数字,求该四位数。结果:1098
For h = 1 To 9
For a = 0 To 9
For z = 1 To 9
For d = 0 To 9
If h * 100 + a * 10 + h + z * 100 + d * 10 + h = z * 1000 + d * 100 + h * 10 + a Then
Print h; a; h
Print z; d; h
Print z; d; h; a
End If
Next d, z, a, h
?求500以内含500能被5或9整除的所有自然数的倒数之和?按四舍五入的方式精确到小数点后第二位1.48
Private Sub Command1_Click()
s = 0
For i = 1 To 500
If i Mod 5 = 0 Or i Mod 9 = 0 Then s = s + 1 / i
Next i
Print Round(s, 2)
End Sub
?求S=1/2+2/3+3/5+5/8的前30项的和(注:该级数从第二项开始,其分子是前一项的分母,'其分母是前一项的分子与分母的和)要求:按四舍五入的方式精确到小数后第二位
结果:18.46
Private Sub Command1_Click()
fz = 1: fm = 2: s = fz / fm
For i = 2 To 30
t = fz: fz = fm: fm = t + fz: s = s + fz / fm
Next
Print Round(s, 2)
End Sub
?当m的值为50时,计算:t=1-1/(2*2)-1/(3*3)-1/(m*m) 四舍五入精确到小数点第四位
结果:0.3749
Private Sub Command1_Click()
t = 1
For n = 2 To 50
t = t - 1 / (n * n)
Next
Print Round(t, 4)
End Sub
?求[1 . 50]之间所有整数能构成直角三角形的三边的组数。例如;3*3+4*4=5*5.它构成直角三角形,所以{3、4、5}为一组,但视{4、3、5}与{3、4、5}为同一组。结果:20
Private Sub Command1_Click()
n = 0
For a = 1 To 50
For b = 1 To 50
For c = 1 To 50
If a ^ 2 + b ^ 2 = c ^ 2 And b > a And c > b Then n = n + 1: Print a, b, c
Next c, b, a
Print n
End Sub
?求[100.900]之间相差为12的素数对的对数,(难题),结果:7
Private Sub Command1_Click()
Dim a(800