Charles Greathouse on Wed, 20 Jul 2016 16:01:59 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: floor(121^(1/2))=10(??)


Zak, I'm not certain I understood what you wanted, but perhaps this will do:

a(n)=my(r=(sqrtint(n)+1)^2,t); for(e=3,logint(n,2)+1, t=(sqrtnint(n,e)+1)^e; if(t<r, r-t)); r

Charles Greathouse
Case Western Reserve University

On Tue, Jul 19, 2016 at 10:20 AM, William F Hammond <hammond@csc.albany.edu> wrote:
Zak Seidov <zakseidov@yahoo.com> writes:

> OK, I understand, that sometimes floor is wrong.
> But plz  help to write a code for computing perfect power number
> . . .


Perhaps you want something like:

  myfloor(x)={local(t);t=sqrt(x);floor(t+1/(10^(2+precision(t))))}

(There's probably a more efficient way to enter the small correction.)


                                    -- Bill