Ruud H.G. van Tol on Wed, 01 Mar 2023 10:59:46 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [seqfan] An unexpected formula related to the Hamming weight of integers
|
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: [seqfan] An unexpected formula related to the Hamming weight of integers
- From: "Ruud H.G. van Tol" <rvtol@isolution.nl>
- Date: Wed, 1 Mar 2023 10:58:28 +0100
- Delivery-date: Wed, 01 Mar 2023 10:59:46 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=isolution.nl; s=soverin; t=1677664713; bh=12AHpXaiE+RQUXLwkYab1z4ChwXSqd1mwnwm9WUeYqg=; h=Date:Subject:To:References:From:In-Reply-To:From; b=oUxI+W88n13fDtbIM6qSPcomOsJiE3/6RkPaOAYVZRaf66Z+TfNRhMavrqFI7bV7w qFsBn6+3UEwHzY1ULH39zGFHYsoPjLYfrHoqTJsksEIS8bV0R08HvCHXcx59oxDKPi snedMzz2DhsfjWFv5D4V+/X0tk+V8IK3eJIWCIuIK63RHub+R18l7AQSGWs5x2JsbI U3VrCvzzb3Db1SzqqwkTiSuWVfBoVwIIGniq0OEVa1FjqlGlIGJmlCWy5hEFfMqtQU Y9b2Req6jVy8rDmcbzQkSbR2+tmZhjURcMZFF5poTua2VGy4tXHDnfs+Es6DiifJ6r INVwXjskUne8Q==
- In-reply-to: <bd31e361-ab9-9fe0-de38-d62961e5f9b7@gmx.com>
- References: <bd31e361-ab9-9fe0-de38-d62961e5f9b7@gmx.com>
On 2023-02-28 19:54, Thomas Baruchel wrote:
Pari/GP [...] floor(log(n+1)/log(4)+1);
Consider using logint() for such cases:
-- -- -- -- -- -- --
? ??logint
logint(x,b,{&z}) [...]
Return the largest integer e so that b^e <= x
[...] replace floor( log(x) / log(b) )
which may not give the correct answer
since PARI does not guarantee exact rounding.
-- -- -- -- -- -- --
floor( log(n+1) / log(4) + 1 )
->
floor( log(n+1) / log(4) ) + 1
->
logint( n+1, 4 ) + 1
-- Ruud