Skip to main content
5 of 5
added 429 characters in body
loopy walt
  • 16.8k
  • 2
  • 11
  • 69

Python 2, 27 bytes

f=lambda n:n>n%3/2>-f(n/3) 

Try it online!

Swaps True and False.

Python 2, 29 bytes (@xnor)

f=lambda n:n<1or n%3<2*f(n/3)

Try it online!

Thanks to @Jonathan Allan for convincing me that @xnor's switching to A005836 (without its first element) is actually perfectly good.

Python 2, 31 bytes (@KevinCruijssen)

f=lambda n:n<2or n%3>0<f(n/3+1)

Attempt This Online!

Improved logic is inspired by @alephalpha's PARI/GP answer. Could save another two bytes by allowing any nonzero value for True.

Python, 33 bytes

f=lambda n:n<2or n%3and f(n//3+1)

Attempt This Online!

Uses the base 3 characterisation at OEIS. Returns 0 and True.

loopy walt
  • 16.8k
  • 2
  • 11
  • 69