Read one integer n, then print the numbers from 1 to n inclusive, one per line – except:
- if the number is a multiple of both 4 and 7, print
AlphaBetainstead - if it’s a multiple of 4 only, print
Alpha - if it’s a multiple of 7 only, print
Beta
This is a for loop with an if/else if/else chain inside it, and the classic trap is branch order: the
“multiple of both” check has to come first, because a number that’s a multiple of 28 is also a multiple of 4, so
a naive “check 4 first” chain would report Alpha and never reach the combined case.