jinzeyu 当前离线
六级士官
@echo off&setlocal enabledelayedexpansion&echo 2 是质数&(for /l %%a in (3,2,1000) do call:1 %%a)&echo 计算完成&pause>nul&exit :1 set a=32&if %1 lss 32 set /a a=%1-1 for /l %%b in (3,2,!a!) do ( set /a i=%1%%%%b if "!i!"=="0" (set $%1=.&goto 2) ) :2 if not defined $%1 echo %1 是质数复制代码
TOP
cjiabing (甲兵时代)当前离线
荣誉版主
质数0.素数:13 质数1.素数:17 质数2.素数:19 质数3.素数:23 质数4.素数:29 质数5.素数:31 质数6.素数:37复制代码
2 是质数 37 是质数 41 是质数 43 是质数 47 是质数复制代码
3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99复制代码
RuiIsRui 当前离线
二级士官
@echo off&setlocal Enabledelayedexpansion set/a MinShu=10 set/a MaxShu=1000 set/a N=0 for /l %%i in (%MinShu%,1,%MaxShu%) do ( set/a JShu=%%i call:AA ) echo %MinShu% ~ %MaxShu% 有 %N% 个质数 pause exit :AA for %%i in (2,3,5,7,11) do ( set/a b=%JShu%%%%%i if "!b!"=="0" GOTO:eof ) set/a MinShu2=%JShu%/10 for /l %%i in (12,1,%MinShu2%) do ( set/a d=%JShu%%%%%i if "!d!"=="0" GOTO:eof ) echo 质数%N%.素数:%JShu% set/a N+=1 GOTO:eof复制代码
find 当前离线
少将
applba 当前离线
中校
@echo off SETLOCAL EnablEdElayEdExpansion for /l %%a in (3,1,100) do ( set /a flag=1 set /a n=%%a-1 for /l %%A in (2,1,!n!) do ( set /a r=%%a %% %%A if !r! equ 0 ( set /a flag=0 ) ) if !flag! equ 1 set "s=!s! %%a" ) echo %s% pause复制代码
Demon 当前离线
上尉
Input: an integer n > 1 Let A be an array of Boolean values, indexed by integers 2 to n, initially all set to true. for i = 2, 3, 4, ..., while i ≤ n/2: if A[i] is true: for j = 2i, 3i, 4i, ..., while j ≤ n: A[j] = false Now all i such that A[i] is true are prime.复制代码
ivor 当前离线
上校