Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Find the first number from 100 upwards that can be divided by both 6 and 8. Use a loop and break. Show the number.
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, go through the solution one step at a time, and check each step against your own.
Plan. Go through the numbers from 100 up. The first number that passes the test is the answer, so leave the loop with break.
The upper limit 1000 is a safe limit: the answer is found long before it.
Check. 120 is divisible by both 6 and 8 (120 = 6 times 20 = 8 times 15). Is there a smaller number from 100? 108 is divisible by 6 but not by 8. 112 is divisible by 8 but not by 6. 114 and 116 fail as well. So 120 is the first.
Answer: 120.
Log in to join the discussion.
Loading…