Skip to main content
2 of 3
deleted 5 characters in body
Level River St
  • 26.7k
  • 4
  • 37
  • 105

#C, score 5#

Works up to 23, not guaranteed above that.

( ((n+4)>>2)&4 ) + n & 15

((n+4)>>2)&4 returns 4 for n>=12. Add it to n and you get the right answer in the least significant 4 bits, then truncate the other bits.

Level River St
  • 26.7k
  • 4
  • 37
  • 105