Determine whether rational coordinates are in the right Sierpinski triangle
Python 2, 68

lambda n,d,N,D:1&gt;=n/d&gt;=0&lt;=N/D&lt;=1and(n&lt;&lt;abs(D*d))/d&amp;(N&lt;&lt;abs(D*d))/D&lt;1


A nice way to check for gasket membership made ugly. If we were guaranteed that the inputs are non-negative and in the unit square, we would have 38:

lambda n,d,N,D:(n&lt;&lt;D*d)/d&amp;(N&lt;&lt;D*d)/D&lt;1


The idea is that we check whether a point lies within the gasket by checking whether their binary fraction expansions bitwise-AND to 0. To get the first k character of the expansion, we bit-shift the numerator k bits left before integer-dividing by the denominator. We need to make k sufficiently large to catch a repeat. We note that the binary expansion n/d has period at most d, so the joint expansions have period at most d*D, so k=d*D suffices.

The rest is to check whether the fraction is in the box and insulate against inputs given like -1/-3.