214k views
0 votes
How to prepare and draw a corresponding flowchart to compute the sum and product of all prime numbers between 1 and 50

User Snobojohan
by
3.2k points

1 Answer

3 votes

Answer:

Create boxes with the following content

  • Initialize sum to 0, product to 1 and number to 1
  • Check if number is a prime. If yes, update sum += number and product *= number
  • Increase number by 1
  • If number is <= 50, go back to "check" block.

The check block has a diamond shape.

At the "yes" branch of the check block, you can create separate blocks for updating the sum and the product.

Connect the blocks using arrows.

Indicate the start and the end of the flow using the appropriate symbols.

The block to check if a number is a prime you could further decompose into the steps needed to do such a check.

User Rombarcz
by
3.7k points