The Dink Network

Reply to Re: Square Root

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
February 1st 2004, 10:32 PM
custom_simon.gif
SimonK
Peasant He/Him Australia
 
Try this:

int &mynumber;
int &f1 = 3;
int &f2;
int &avg;
int ÷
int &sqroot;

//assign a value to the &mynumber variable
&mynumber = //how ever you get this

&f2 = &mynumber;
&f2/&f1;

loop:
&avg = &f1;
&avg += &f2;
&avg / 2;

&div = &mynumber;
&div/&avg;
&f1 = ÷
&f2 = &avg;
if (&f1 < &f2) goto loop;

&sqroot = &f1;
&sqroot += &f2;
&sqroot / 2;

//Now the value in &sqroot should be (at least close to as an integer) the square root of &mynumber.

I've not tested this... but it should work