AI Tutor
Imagine you have 73 pieces of candy and want to share them equally with your friends without cutting a single piece. Is it possible, or is 73 a stubborn prime number that refuses to be split?
To solve this with computers, we use the modulo operator (written as %), which calculates the remainder when one integer divides another. A number nn is divisible by dd if n%d==0n \% d == 0 with zero remainder.
Can we turn this simple remainder check into an automated decision-making machine?

The Divisibility Flowchart

A flowchart uses standard shapes to map an algorithm: rounded rectangles for Start/End, diamonds for decision points, and rectangles for processing steps.
Testing one divisor is easy, but what if we need to test every possible factor to prove a number is prime?

Building a Prime Tester

A prime number is a whole number greater than 1 whose only positive factors are 1 and itself. In 240 BCE, Greek mathematician Eratosthenes invented the first systematic algorithm to filter out composite numbers.
To test if nn is prime, we set a loop counter d=2d = 2 and check if n%d==0n \% d == 0. If any divisor leaves no remainder, nn is composite; if none do after checking all possibilities, nn is prime.
Checking every number up to n−1n-1 works, but for a number like 1,000,001 that would take a million steps. Can we stop much earlier?