Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
binairy tree climbing solution in Clear category for Exploring Calkin-Wilf Tree by Tinus_Trotyl
def calkin_wilf(n: int) -> tuple[int, int]:
a, b = 1, 1
for x in bin(n)[3:]: # for all less significant bits of binairy number "n"
match x:
case "0": a, b = a, a + b
case "1": a, b = a + b, b
return a, b
Dec. 23, 2023
Comments: