- @echo off
- :begin
- cls&setlocal enabledelayedexpansion
- set/p s=please input number:
- set/a n=1
- :loop
- set/a n+=1,x=2*s-n*n-n,y=2*n,mod=x%%y,a=x/y,m=(n*n+n)/2
- if %mod% equ 0 (
- for /l %%i in (1,1,%n%) do (
- set/a a+=1&set "str=!str!!a!+"
- )
- echo %s%^=!str:~,-1!&set "str="
- )
- if %m% gtr %s% (pause&endlocal&goto begin) else goto loop
复制代码
|