- @echo off&setlocal enabledelayedexpansion
- for %%i in (0 2 4 5 6 8) do set "_%%i=a"
- echo 1-1000內的素數如下:>素數.txt
- for /l %%a in (1,1,1000) do (
- set "str=%%i"
- if not defined _!str:~-1! (
- set /a a=%%a/2+1,num=0
- call :lp %%a
- )
- )
- start 素數.txt
- goto :eof
- :lp
- for /l %%i in (1,1,%a%) do (
- set /a b=%1/%%i*%%i
- if !b! equ %1 set /a num+=1
- if !num! equ 2 goto :eof
- )
- if %num% lss 2 echo %1 >>素數.txt
复制代码
|