测试代码(里有一bug,不知各位是否测试的出来,目前并不明白bug产生原因)- @echo off&setlocal enabledelayedexpansion
- :start
- cls
- set "str=1"
- set /p EN=请输入一个数字:
- call :CheckPrime %EN% Prime Remainder
- set str=%str% x !OBJ!
-
- if "!str:~-2,1!"=="1" set str=!str:~0,-4!
- if not "!str:~-6,1!"=="1" set str=!str:~4!
-
- echo.&echo %EN% = !str!
- pause>nul
- goto :start
-
- :CheckPrime OBJ Prime Remainder
- set /a OBJ=%~1,Remainder=0
- set /a var=!OBJ!/2+1,var_=!OBJ! %% 2
- if !var_! EQU 0 (
- set str=!str! x 2
- set/a Prime=2,Remainder=!OBJ!/2
- call :CheckPrime !Remainder! Prime Remainder
- )
- for /l %%i in (3 2 !var!) do (
- set /a var_=!OBJ! %% %%i
- if !var_! EQU 0 (
- set str=!str! x %%i
- set/a Prime=%%i,Remainder=!OBJ!/%%i
- call :CheckPrime !Remainder! Prime Remainder
- )
- )
复制代码
|