Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
ActivePattern
· 1y ago · 0 comments
Doing a single modulo 9 operation is much faster than summing a d-digit number, which requires d modulo 10s, d divide 10s, and d sums.
Comments
[–]
brabel
1y ago
You can do the sum by looking directly at the digits in the string, no need for module at all.
[–]
Jensson
1y ago
Number to string is even more expensive.