代碼如下:
Set regex = New RegExp
regex.Pattern = "^1?$¦^(11+?)\1+$"
For i = 1 To 100
If Not regex.Test(String(i,"1")) Then
WScript.Echo i
End If
Next
看到標題你一定會不屑一顧,枚舉質(zhì)數(shù)誰不會?
代碼如下:
For i = 1 To 100
For j = 2 To i
If i Mod j = 0 Then Exit For
Next
If j = i Then WScript.Echo i
Next
幾行代碼就能搞定,如此簡單。那就看看下面這個程序吧!
代碼如下:
Set regex = New RegExp
regex.Pattern = "^1?$|^(11+?)\1+$"
For i = 1 To 100
If Not regex.Test(String(i,"1")) Then
WScript.Echo i
End If
Next
更多信息請查看IT技術(shù)專欄