> < ^ Date: 27 Sep 2002 12:28:14 +0200
> < ^ From: Neilen <nmarais@hertz.ee.sun.ac.za >
> < ^ Subject: Re: Ceiling of a square root

gap forum

Hi Sven.

On Fri, 2002-09-27 at 05:17, Sven Reichard wrote:
> Dear GAP-Forum
> 
> On Fri, 27 Sep 2002, Neilen wrote:
> 
> > Hi all.
> > 
> > I'm looking to get the integer ceiling of a square root.  RootInt gives
> > one the floor (ie RootInt(2) = RootInt(3) = 1, RootInt(5) = 2), while I
> > would want them to be respectively 2,2 and 3.
> > 
> > Thanks
> > Neilen

Well, yes, I ended up writing my own function too. Just seemed a bit
arb to have to though... In any case, will your function not be wrong if
n-1 is a perfect square? Perhaps I should have specified that
RootIntCeiling(4) = 2.

> RootIntCeiling := function(n)
>   if n = 0 then
>     return 0;
>   fi;
>   return 1 + RootInt(n-1);
> end;
> 
> Sven Reichard.
Cheers
Neilen

>
> --
> Sven Reichard
> Dept. of Math. Sci.
> University of Delaware
> reichard@math.udel.edu
>
>
>
--
all we are waiting for is something worth waiting for
--- KMFDM


> < [top]