Skip to content

Instantly share code, notes, and snippets.

@bparanj
Created July 13, 2020 22:28
Show Gist options
  • Select an option

  • Save bparanj/33939ed48771ffb74de8d94fd738fe80 to your computer and use it in GitHub Desktop.

Select an option

Save bparanj/33939ed48771ffb74de8d94fd738fe80 to your computer and use it in GitHub Desktop.
def xor_operation(n, start)
number = 0
for i in (0..n-1) do
number ^= start + 2*i
end
number
end
# Input: n = 5, start = 0
p xor_operation(4, 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment