WARNING: This program has a logic error. See if you can recognize the logic error happening.

  • Click Run and enter a number for input. Look at the random number generated for the cookies.
  • Does the output of the program make sense? Double check the math! How come there are always leftovers?

Modulo returns a remainder, but we need to use modulo with == to check that something is evenly divisible!

  • Fix the logic error by replacing True in the if statement with 0. It will never equal True!

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)