In a past lesson, we learned how to use the % or "mod" operator to test if one
number is divisible by another number. A simple divisibilty tester was made using this
idea.
In this lesson, we'll use a for-loop to (exhausively) check through every number up to a number you wish to test.
In this way, we can find all factors of a given number.
Now you try. Fix the if statement to have a condition that will be true if i divides evenly into num.
Type your code here:
See your results here:
This code will not run. What will you fill into the if statement to test if num is divisible by i?
Dismiss.
Show a friend, family member, or teacher what you've done!
Here is a share link to your code:
Does your code work? Want to run it on your iPhone?
Here's your code:
Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.
Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into
this page
Then click the "Use on iPhone" button that you'll see.