117k views
11 votes
Write an algorithm to sum all numbers between 0 and 1000 that are divisible by ,7​

User Neutreno
by
4.4k points

1 Answer

10 votes

Answer:

The algorithm is as follows:

1. START

2. SUM = 0

3. FOR NUM = 0 TO 1000

3.1 IF NUM % 7 == 0

3.1.1 SUM = SUM + NUM

3.2 END IF

4. END FOR

5. PRINT SUM

6. END

Step-by-step explanation:

This begins the algorithm

1. START

This initializes sum to 0

2. SUM = 0

This iterates from 0 to 1000

3. FOR NUM = 0 TO 1000

This checks if the current number is divisible by 7

3.1 IF NUM % 7 == 0

If yes, the number is added

3.1.1 SUM = SUM + NUM

End the if condition

3.2 END IF

End loop

4. END FOR

This prints the calculated sum

5. PRINT SUM

The algorithm ends here

6. END

User Frank Treacy
by
4.5k points