Counting one person at a time is also inefficient

2 years ago
10.3K

This time, though, line 3 doesn't execute at all since there isn't a person in the room,and so, n remains zero,which indeed matches the number of people in the room.Pretty simple, right?But counting people one a time is pretty inefficient, too, no?Surely, we can do better!Why not count two people at a time?Instead of counting 1, 2, 3, 4, 5, 6, 7, 8, and so forth,why not count 2, 4, 6, 8, and so on?

Loading comments...