The algorithm idea was proposed by terse. I expanded the feasible range.
[ Last edited by dreamseed on 2008-4-5 at 05:13 PM ]
@echo off
set /p n=Enter the number to be square-rooted (0~89999999):
set a=2
:acr
set /a a=(n/a+a)/2,b=a*a
if %b% gtr %n% goto :acr
if %b% lss 0 goto acr
if %b% equ %n% goto :ok
set /a t=n-b,k=a
:loop1
set /a t*=100,x=k*20,m=10
:loop2
set /a m-=1,s=m*(m+x)
if %s% gtr %t% goto loop2
set /a t-=s,c+=1,k=k*10+m,r=r*10+m
if %c% lss 5 goto loop1
:ok
if not "%r%" == "" set a=%a%.%r%
echo Result: %a%
pause>nul[ Last edited by dreamseed on 2008-4-5 at 05:13 PM ]
Recent Ratings for This Post
( 2 in total)
Click for details
沉浸于脚本的流浪客。
纳须弥于芥子,容世界之脚本...
纳须弥于芥子,容世界之脚本...
