🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Rick Peralta Fri, 06 Sep 1985 14:21
sqrt
#237
Author: Rick Peralta
Date: Fri, 06 Sep 1985 14:21
35 lines
1074 bytes
This is'nt really quick or smart, but I think it works for most cases.

N - the number to find the root of.
R - resolution of the answer.
I - latest increment.
V - latest value to test.

sqrt(N)
{
    R = .01
    I = N / 2
    V = I
    if (N < 0) barf

    loop:
	I = N / 2
	if ( (V*V) > N+R )
	{
	    V = V - I
	    goto loop
	}
	else
	if ( (V*V) < N-R ) 
	{
	    V = V + I
	    goto loop
	}
    return V
}

Sorry for the pseudo code, I don't speak forth too well.

Rick  ...!cybvax0[!dmc0]!fbp

"Life is a compromise"
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads