Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Write a program that says if a whole number is divisible by . What does it say for and for ?
n % d == 0 means that n is divisible by d.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
Plan. A number is divisible by 7 when the remainder after dividing by 7 is 0.
if n % 7 == 0: shows that it is divisible.else: shows that it is not.Check. , so the remainder is : divisible. , so the remainder is : not divisible.
Log in to join the discussion.
Loading…