| |
| | [No title] (Site not responding. Last check: 2007-10-20) |
 | | function [ q, r ] = i_sqrt (n) %% I_SQRT finds the integer square root of N by solving N = Q**2 + R. % Discussion: % % The integer square root of N is an integer Q such that % Q**2 <= N but N < (Q+1)**2. |
 | | % % Parameters: % % Input, integer N, the number whose integer square root is desired. |
 | | % % Output, integer Q, R, the integer square root, and positive remainder, % of N. n_abs = abs (n); q = n_abs; if (0 < n_abs) while (floor (n_abs / q) < q) q = floor ((q + floor (n_abs / q)) / 2); end end r = n_abs - q * q; |
| www.csit.fsu.edu /~burkardt/m_src/subset/i_sqrt.m (214 words) |
|