A140820 Triangle read by rows: T(n,k) = 1 if and only if the Gray codes for n and k have no bits in common.
1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0
Offset: 0
Examples
Triangle begins as: 1; 1, 0; 1, 0, 0; 1, 1, 0, 0; 1, 1, 0, 0, 0; 1, 0, 0, 0, 0, 0; 1, 0, 0, 1, 0, 0, 0; 1, 1, 1, 1, 0, 0, 0, 0; 1, 1, 1, 1, 0, 0, 0, 0, 0; 1, 0, 0, 1, 0, 0, 0, 0, 0, 0; 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
Links
- G. C. Greubel, Rows n = 0..100 of the triangle, flattened
Crossrefs
Cf. A131218.
Programs
-
Magma
A140280:= func< n,k | BitwiseAnd(BitwiseXor(n, ShiftRight(n, 1)), BitwiseXor(k, ShiftRight(k, 1))) eq 0 select 1 else 0 >; // based on Kevin Ryde's code [A140280(n, k): k in [0..n], n in [0..15]]; // G. C. Greubel, Sep 05 2025
-
Mathematica
A140820[n_, k_]:= Boole[BitAnd[BitXor[n,BitShiftRight[n,1]], BitXor[k,BitShiftRight[k, 1]]]==0]; (* based on Kevin Ryde's code *) Table[A140280[n,k], {n,0,12}, {k,0,n}]//Flatten (* G. C. Greubel, May 30 2019; Sep 05 2025 *)
-
PARI
T(n,k) = !bitand(bitxor(n,n>>1), bitxor(k,k>>1)); \\ Kevin Ryde, Jul 13 2020
-
SageMath
def A140820(n,k): return int( (n^^(n>>1)) & (k^^(k>>1)) ==0) # based on Kevin Ryde's code print(flatten([[A140820(n, k) for k in range(n+1)] for n in range(16)])) # G. C. Greubel, May 30 2019; Sep 05 2025
Extensions
Edited by G. C. Greubel, May 30 2019
New title from Charlie Neder, Jun 03 2019
Offset changed by G. C. Greubel, Sep 05 2025
Comments