1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
OverLord2011 [107]
3 years ago
11

Write a recursive function to compute sum of first N integers starting with 1.

Computers and Technology
1 answer:
Citrus2011 [14]3 years ago
4 0

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// recursive function to find sum from 1 to n

int recur_Sum(int n)

{ // base condition

if (n <= 1)

 return n;

// recursive call

return n + recur_Sum(n - 1);

}

// main function

int main()

{

   // variables

   int n;

   cout<<"Enter a number:";

   // read the number

   cin>>n;

   // print the sum

   cout<<"Sum of first "<<n<<" integer from 1 to "<<n<<" is:"<<recur_Sum(n);

return 0;

}

Explanation:

Read a number from user and assign it to variable "n".Call function recur_Sum() with parameter "n".This function will recursively call itself and find the Sum of first n numbers from 1 to n.Then function will return the sum.

Output:

Enter a number:10

Sum of first 10 integer from 1 to 10 is:55

You might be interested in
You do not have to move your fingers to click the top row reach keys.<br> 1. True <br> 2. False
Kazeer [188]
False you have to move your fingers
3 0
2 years ago
The Chart below from Google Trends shows the prevelance of some search terms in the United States between 2004 and the present.
ad-work [718]

The question is incomplete. The complete question could be found here: https://www.coursehero.com/file/p655c1i/a-Maintaining-privacy-of-the-information-stored-in-the-data-set-b-Scalability/

Answer:

B. Generally speaking, since 2009 more people use "red" in their search terms more than they use "blue", "yellow", "green", or "purple."

Explanation:

Based on the data provided in the figure, it can be inferred that the color 'red' was used the most in the search terms compared with the other colors such as purple or green. The other colors were also used in the search terms on google, however, the trend of those that used the color 'red' in the search terms is the highest.

8 0
3 years ago
The tag that describes the content of the web page is ________________
makkiz [27]

Answer:

<body>

Explanation:

the content of the web page must be body.

4 0
3 years ago
An example of what you can post that shows kindness to other
harina [27]

Answer:

everybody is awesome

Explanation:

5 0
2 years ago
Which of the following shows a list of Big-Oh running times in order from slowest to fastest?
Rufina [12.5K]

Answer:

O(N!), O(2N), O(N2), O(N), O(logN)

Explanation:

N! grows faster than any exponential functions, leave alone polynomials and logarithm. so O( N! ) would be slowest.

2^N would be bigger than N². Any exponential functions are slower than polynomial. So O( 2^N ) is next slowest.

Rest of them should be easier.

N² is slower than N and N is slower than logN as you can check in a graphing calculator.

NOTE: It is just nitpick but big-Oh is not necessary about speed / running time ( many programmers treat it like that anyway ) but rather how the time taken for an algorithm increase as the size of the input increases. Subtle difference.

5 0
2 years ago
Read 2 more answers
Other questions:
  • Traffic collisions are among the top killers of children in America.
    13·1 answer
  • Which of the following is software? : Monitor Mouse Windows Keyboard Printer
    13·1 answer
  • The function below takes a string argument sentence. Complete the function to return the second word of the sentence. You can as
    5·1 answer
  • Why is compression a "hard problem" for computers? Draw on your own experience compressing text with the text compression widget
    12·1 answer
  • Which routing protocol does an exterior router use to collect data to build its routing tables?
    8·1 answer
  • EASY POINTS what favorate food<br> so easy
    7·2 answers
  • Who are the following furries?
    10·2 answers
  • What is the difference between a crosstab query and a subquery?
    11·2 answers
  • Elan inserted shapes into a slide in his presentation. What is the quickest way to format those shapes?
    8·1 answer
  • Match each type of video camera to its features:
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!