← Control Flow

Loop Labels

medium

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 AlphaBeta instead
  • 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.

Your solution

"Run" uses the sample stdin ("10"). "Submit" checks your code against all 3 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution