R
R
raster2020-12-22 21:04:19
Algorithms
raster, 2020-12-22 21:04:19

Formula expression from task?

Problem: given a segment of numbers [A, B]. We need to find the number of those numbers that are divisible by 3 without a remainder.
How to express the formula for this problem. If you just sort through the numbers - time limit.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmshar, 2020-12-22
@Rastr_0

Lord, as much as possible. Well, at least elementary learn how to work with a search!
Take A, A+1, A+2. See which of them is divisible by 3. Let this number be equal to C. Then take all the numbers C + 3, C + 2 * 3, C + 3 * 3 .... C + N * 3 less than B. That's it. What is the time limit??
Well, you can also divide B-.A by three, if you are only interested in the number.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question