Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
lblume
18 days 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]
Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: