Skip to main content

Practice ยท 2 of 3

Width-Independent Loop

CHALLENGE
Difficulty: advanced+25 XP

ISO C. Implement unsigned long long checksum_upto(unsigned long long n) โ€” sum i from 0 to n-1 using unsigned long long (the widest unsigned this course assumes) and return the total. The point: the math must be correct for any n representable in unsigned long long, without ever falling into signed-overflow UB.

Back to lesson: Practice: Portability Probes