235k views
4 votes
PLEASE HELP I NEED THE ANSWER FOR MY HOMEWORK TODAY!!! Draw a flow diagram for an algorithm which calculates how many numbers 1, 2, 3…n have to be added to reach a total greater than 500. Output the answer n.

User Thomas Q
by
5.5k points

1 Answer

5 votes

Step-by-step explanation:

Lets use arithmetic progression

so S= n(2a₁ + (n-1)d /2 assuming common difference is 1

so sum must be greater than 500

⇒n² +n /2 >500

⇒n² + n >1000

⇒n² + n -1000>0

For the algorithm

For int n =1 to ∞ ,

if n² + n -1000<0

then continue

else print (n)

PLEASE HELP I NEED THE ANSWER FOR MY HOMEWORK TODAY!!! Draw a flow diagram for an-example-1
User Lauree
by
5.2k points