-
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- ::算法原理:http://zh.wikipedia.org/wiki/%E5%8B%BE%E8%82%A1%E6%95%B0
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- @echo off||Code By plp626
- ::勾股数中最小的一个数 < MAX^2 这里暂定MAX=30
- set MAX=30 & if not %1.==. goto%*
- echo 稍等。。。
- for /f "delims=" %%a in ('%~s0 :rtnum^|sort')do echo.%%a
- pause&exit/b
- :rtnum
- setlocal enabledelayedexpansion&set "s= "
- for /l %%n in (1 1 %MAX%)do (set/a tp=%%n+1
- for /l %%m in (!tp! 2 %MAX%)do (call:ifprime %%m %%n prm
- if !prm! equ 1 (
- set/a mm=%%m*%%m,nn=%%n*%%n,a=mm-nn,b=2*%%m*%%n,c=mm+nn
- set a=%s%!a!&set b=%s%!b!&set c=%s%!c!
- if !a! lss !b! (echo !a:~-7! !b:~-7! !c:~-7!) else echo !b:~-7! !a:~-7! !c:~-7!
- )))
- exit/b
- :ifprime
- set/a x=%1,y=%2
- :loop
- set/a r=x%%y,x=y,y=r
- if %r% neq 0 (goto:loop) else set %3=%x%
复制代码
|