Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
lblume
6 months ago
|
parent
|
context
|
favorite
| on:
That XOR Trick (2020)
You can also calculate the XOR-accumulation of all values between 1 and n in O(1) using a lookup table like this:
[n, 1, n+1, 0][n%4]
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: