Benja303

11-21-2012, 08:15 PM

I need to create a pseudocode to calculate the sum of the multiples of 4 and 7 between a certain range m and n which will be inputted by the user.

Here is what i tried so far

Begin

Display “Please enter the smaller number in your range”

Input m

Display “Please enter the larger number in your range”

Input n

Incrementor=1

DO

Multiples4=4*incrementor

Multiples7=7*incrementor

IF Multiple4 <=n AND >=m

Sum=Sum+Multiples4

Endif

IF Multiples7 <=n AND >=m

Sum=Sum+Multiples7

Endif

Incrementor=incrementor+1

WHILE Multiples4 and Multiples7 <=n

It's just a snipped but There are many problems with this as you can see. A friend of mine was suggesting divide by the number and then check to see if there is a remainder instead or something. I need some help. Please suggest a method

Here is what i tried so far

Begin

Display “Please enter the smaller number in your range”

Input m

Display “Please enter the larger number in your range”

Input n

Incrementor=1

DO

Multiples4=4*incrementor

Multiples7=7*incrementor

IF Multiple4 <=n AND >=m

Sum=Sum+Multiples4

Endif

IF Multiples7 <=n AND >=m

Sum=Sum+Multiples7

Endif

Incrementor=incrementor+1

WHILE Multiples4 and Multiples7 <=n

It's just a snipped but There are many problems with this as you can see. A friend of mine was suggesting divide by the number and then check to see if there is a remainder instead or something. I need some help. Please suggest a method