WDI Fundamentals Unit 8
This exercise may be familiar to some of you — your job is to write some code that, depending on the value of
x, assigns one of several values to
xis evenly divisible by both 3 and 5 (for example, 15 or 30), set
xis evenly divisible by 3 (for example, 3, 6, or 9), set
xis evenly divisible by 5 (for example, 5 or 10), set
xis not evenly divisible by either 3 or 5 (for example, 7), set
Don't remember how to determine if something divides evenly? Review the modulus (
To test your code, set a value for
result into the "Console" panel and hit the enter/return key. Did you get the result you expected? Try out several different values for
x, just to be sure.
Stuck? Check out the solutions to see what you can do.