编写程序,求n以内所有素数的和,其中n由用户输入。
Private Sub Command1_Click()Dim i, j, sum, flag,n As Integer, m As Integer n =Val(inputBox(“请输入 n”))If n>1 thensum = 0For i = 2 To nflag = 0For j = 2 To i\2If i mod j=0 Then flag = 1NextIf flag = 0 Then sum = sum + iNextPrint “n 以内所有的素数和为: ”,sum End ifEnd Sub