Re: Unsigned Integer Restraint Errors



On Mar 13, 9:41 am, "Adam Beneschan" <a...@xxxxxxxxxx> wrote:
On Mar 13, 9:04 am, "Adam Beneschan" <a...@xxxxxxxxxx> wrote:

By the way, if I were going to write a loop that goes from 2 to
sqrt(n)/2 + 1, I wouldn't use Sqrt like this:

for I in 2 .. Integer(Float'Floor(Sqrt(Float(N))/2.0)) + 1 loop...

but rather, I'd just write it something like this:

I := 2;
while (2 * I - 1) * (2 * I - 1) <= N loop -- I think I got this
right

No, I didn't. Jeff did. I must have read (sqrt(n)+1)/2 or
something. Oops.

Ooops again---I meant Dmitry, not Jeff. Wow, I'm off to a really good
start today.

-- Adam



.



Relevant Pages