Skip to main content
2 of 2
Commonmark migration

Ruby, 26 bytes

anonymous function with iteration.

->n{a=1;n.times{a^=a*2};a}

this recursive function is one byte shorter, but as it needs to be named to be able to refer to itself, it ends up one byte longer.

f=->n{n<1?1:(s=f[n-1])^s*2}
Level River St
  • 26.7k
  • 4
  • 37
  • 105