Math, asked by biswadipsarkar4523, 1 year ago

Draw a flow chart to find the sum of all multiples of 5 up to a given no.

Answers

Answered by RajKvyasRajput
0

Answer:

If you dont mind i think your question is not clear so plz clear the question bcz the number is not given

Thanks

Answered by nksinha36
0

Consider that A = 5 * n (A is a multiple of 5)

The multiple of 5 that is not greater than B is

Z = B - (B mod 5)

So the problems becomes: “sum all multiples of 5 between A and Z (included)”.

Now, Z is also a multiple of 5, therefore

Z = 5 * (n + m)

and assume also that Z >= A

Therefore the result is

5 * (n) + 5 * (n + 1) + 5 * (n + 2 ) … + 5 * (n + m)

which is also

5 * ((n)+(n+1)+(n+2) … + (n+m))

and therefore is also

5 * ((n + n + … ) + (1 + 2 … + m))

which in turn is

n = A / 5;

Z = B - (B mod 5)

m = (Z / 5) - n

result = 5 * ((n * (m + 1) + (m * (m +1)) / 2)

Example:

A = 15, B = 36

n = 15 / 5 = 3

Z = B - (B mod 5) = 36 - 1 = 35

m = (35 / 5) - 3 = 7 - 3 = 4

result = 5 * ((3 * 5) + (4 * 5 / 2)) = 5 * (15 + 10) = 5 * 25 = 125

which is the same as

result = 15 + 20 + 25 + 30 + 35 = 125

Therefore, your flow chart is just a single step computing the result. For clarity, you may want to split it into multiple steps.

Similar questions