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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started