Question: Design an algorithm and write its C++ code. that takes one positive integer argument, call it my_goal and returns as its value the smallest positive
Design an algorithm and write its C++ code. that takes one positive integer argument, call it "my_goal" and returns as its value the smallest positive integer n for which 1+2+3+. . . +n is at least equal to my_goal.
The solution must also check that the input is a positive integer and otherwise it should print an error message:
The '9' should outcome '4' because 1+2+3+49 and 1+2+3<9;
The '21' should outcome '6' because 1+2+3+4+5+621 and 1+2+3+4+5<21;
Keep your code commented and indented for ease of reading. Paste your commented codes in the solution and also add a clear screen shot of outcome in your solution.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
