1 int computeArithmeticProgression(int num) { int sum = 3 for (int i 1; i <= num; i++) { 4 sum += i; }

New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Patrick M. Carey
Chapter14: Exploring Object-based Programming: Designing An Online Poker
Section14.1: Visual Overview: Custom Objects, Properties, And Methods
Problem 7QC
icon
Related questions
Question

Consider the method provided in the image attached below.  Provide the instruction count in the average case for this method (lines 2, 3, 4, and 6).  Answer with the following format:
line #: Instruction count

1
int computeArithmeticProgression(int num) {
2
int sum =
0;
for (int i
1; i <= num; i++) {
4
sum += i;
5
}
6
return suM;
7 }
Transcribed Image Text:1 int computeArithmeticProgression(int num) { 2 int sum = 0; for (int i 1; i <= num; i++) { 4 sum += i; 5 } 6 return suM; 7 }
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning