Ruud H.G. van Tol on Mon, 19 Dec 2022 05:40:07 +0100

 Binary Complement Sequences

• To: pari-users@pari.math.u-bordeaux.fr
• Subject: Binary Complement Sequences
• From: "Ruud H.G. van Tol" <rvtol@isolution.nl>
• Date: Mon, 19 Dec 2022 05:39:02 +0100
• Delivery-date: Mon, 19 Dec 2022 05:40:07 +0100
• Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=isolution.nl; s=soverin; t=1671424740; bh=fA+d69rgbKhG45p/DdV4yGyHXAiWGKFtlWsNujjx0Y0=; h=Date:To:From:Subject:From; b=Z+tSmp8LXIcTi9P2I/e2AtyxJnw30dHst3RPfRqD7jwdhNdm+KQbiiTdNirDx+fRl lpBkfDC4U3Qyibyy6tYJHbuhqUcLfYpxkahM/ILxvacmMLOKIWytqhOVwJofYIJ1Kx rsoYvWm3VJP19d9Nx2jQL5oiASXMA0FmY0ZL9KruntgsYXRW2No/cyJ+9aK9Vxfh/f CEQy1tX2ltKPLsIDkyAVwZUzM5IkzFl3qMb9OlVu4PRi0wJtvm8ZRw2eCrM7Y9h9TN 0Hkn6VewyIUBIlS0piWUGtKEpn/MA+JavMePE38Q/icB7IBpGb1chZGOSd1pMpI3KB p2OueaSHnUKCA==

```

> on any number:
> -multiply by 3
> -find the binary complement (if it is 1001010 in binary,
> the complement is 0110101).

I created this code:

{ bc3_seqX(n)= my(x=n,i=0);while(x>0,x=bc3(x);i++);
print(n," -> ",x," (",i,")"); }
{ bc3_dropX(n)= my(x=n,i=0);until(x<=n,x=bc3(x);i++);
print(n," -> ",x," (",i,")"); }

Related code on https://oeis.org/wiki/User:Ruud_H.G._van_Tol

? bc3_dropX(22246);
22246 -> 9838 (120796648)
cpu time = 4min, 16,771 ms, real time = 4min, 17,641 ms.

? bc3_seqX(22246);
22246 -> 0 (120796790)
cpu time = 4min, 17,644 ms, real time = 4min, 18,250 ms.

Are there ways to do this faster?

If I inline the bitneg, it becomes:

? bc3_seqX(22246);
22246 -> 0 (120796790)
cpu time = 3min, 39,774 ms, real time = 3min, 40,153 ms.

but I'm of course after a decimation. :)

-- Ruud

```