Skip to content
Better HN
Top
Best
Ask
Show
New
Jobs
Search
⌘K
0 points
AbsoluteCabbage
3y ago
0 comments
Save
Share
Just use n & 1 then. An odd number ends in binary 1; and’ing it with 1 yields 1 if its odd.
0 comments
1 comments · 1 top-level
top
newest
oldest
emodendroket
3y ago
You don't even have to get that cute. Do integer division, multiply the result by the divisor, and subtract the product from the original dividend. Surely you can't say you don't use multiplication, division, and subtraction.
j
/
k
navigate · click thread line to collapse