login
A385395
Triangle read by rows: T(n, k) = [A047999(n, k) = 1 or A385456(n, k) = 1], where [.] is the Iverson bracket.
2
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1
OFFSET
0
LINKS
Michael De Vlieger, Plot of T(n,k), n = 0..511, k = 0..n, at (x,y) = (-n,k-n/2), showing T(n,k) = 1 in black and T(n,k) = 0 in white.
FORMULA
T(n, k) = [(n & k = k) or ((n mod 3 >= k mod 3) and (~floor(n/3) & floor(k/3) = 0))], where '&' denotes the bitwise 'and', '~' the bitwise complement, and [.] is the Iverson bracket.
EXAMPLE
Triangle begins:
[0] 1;
[1] 1, 1;
[2] 1, 1, 1;
[3] 1, 1, 1, 1;
[4] 1, 1, 0, 1, 1;
[5] 1, 1, 1, 1, 1, 1;
[6] 1, 0, 1, 0, 1, 0, 1;
[7] 1, 1, 1, 1, 1, 1, 1, 1;
[8] 1, 1, 1, 0, 0, 0, 1, 1, 1;
[9] 1, 1, 0, 1, 0, 0, 1, 0, 1, 1;
MAPLE
with(Bits): IB := b -> subs([true=1, false=0], b): # Iverson Bracket
isT := (n, k) -> And(n, k) = k or (modp(n, 3) >= modp(k, 3) and And(Not(iquo(n, 3)), iquo(k, 3)) = 0):
for n from 0 to 12 do seq(IB(isT(n, k)), k = 0..n) od;
MATHEMATICA
isT[n_, k_] := BitAnd[n, k] === k || (Mod[n, 3] >= Mod[k, 3] && BitAnd[BitNot[Quotient[n, 3]], Quotient[k, 3]] === 0);
Table[Boole[isT[n, k]], {n, 0, 12}, {k, 0, n}] // Flatten
PROG
(Python)
def T(n: int, k: int) -> int:
if n & k == k: return 1
nd, nm = divmod(n, 3)
kd, km = divmod(k, 3)
return int((nm >= km) and ((kd & nd) == kd))
# Or with:
def isT(n, k): return (n & k == k) or ((n % 3 >= k % 3) and (((~(n // 3)) & (k // 3)) == 0))
CROSSREFS
Sequence in context: A108358 A267959 A144384 * A144475 A011758 A015088
KEYWORD
nonn,tabl
AUTHOR
Peter Luschny, Jul 03 2025
STATUS
approved