Knowee
Questions
Features
Study Tools

Write an algorithm (pseudocode) that uses iteration to find the sum of all multiples of 3 and all multiples of 4 between 3 and 150 inclusive. Print the sum.

Question

Write an algorithm (pseudocode) that uses iteration to find the sum of all multiples of 3 and all multiples of 4 between 3 and 150 inclusive. Print the sum.

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is the pseudocode for the problem:

Initialize sum to 0
For each number i from 3 to 150
    If i is divisible by 3 or i is divisible by 4
        Add i to sum
End For
Print sum

Here is the detailed step-by-step explanation:

  1. Initialize a variable sum to 0. This will hold the sum of all multiples of 3 and 4.

  2. Start a loop that goes through each number i from 3 to 150 inclusive.

  3. Inside the loop, check if i is divisible by 3 or 4. You can do this by using the modulus operator (%). If i % 3 == 0 or i % 4 == 0, then i is a multiple of 3 or 4.

  4. If i is a multiple of 3 or 4, add it to sum.

  5. After the loop ends, print the value of sum. This is the sum of all multiples of 3 and 4 between 3 and 150 inclusive.

This problem has been solved

Similar Questions

Find the sum of all 3's that are needed to write the numbers from 200 to 400.

The sum of all integers from 1 to 520 that are multiples of 4 or 5

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3,5,6 and 9. The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000.

Write a program to accept an integer range and print the sum of number that are divisible by either 3 or 5Input Format:An integer range is given inputOutput Format:Print the calculated sum.

2. Devise an algorithm that finds the sum of all the integers in a list

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.