求100以内的素数的和

来源:互联网 发布:月报表软件 编辑:程序博客网 时间:2024/04/20 14:26

Private Sub Command1-click()

   Dim i as integer

   Dim s as integer

   s=0

For  i=2 to 100

if sushu(i) then s=s+i

Next  i

Print s

End  Sub

Function  sushu (n as integer) as boolean

     Dim i as integer

   sushu = True

 For i = 2 to n-1

If  n/i =n/i  then  sushu = false

  Next  i

End Function

心得体会:请老师认真看看这道题,不是大小写的错误,每一步看似也对,但是运行的时候往往会说for 没有next,请问老师哪里错了???

原创粉丝点击