Key Concepts

Review core concepts you need to learn to master this subject

Loops identify divisble integers

int divisor = someNumber; int dividend = anotherNumber; while (dividend >= divisor) { dividend -= divisor; } if (dividend == 0) { // then the dividend is divisible by the divisor }

Loops can be used to identify if an integer is or is not evenly divisible by another integer. By the end of the loop, if the dividend is 0, then we know that there are no leftovers and it is evenly divisible by the divisor.