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
AlekseyPX
3 years ago
14

Write a recursive function program to find the nth element in the following arithmetic numerical sequence: 3, 11, 27, 59, 123, .

..
Computers and Technology
1 answer:
olga2289 [7]3 years ago
8 0

following are the code in c++

#include<bits/stdc++.h>

using namespace std;

//fuction to find nth term of the sequence

int val(int n){

  if(n==1){

      return 3;

  }else{

      return val(n-1)+8*pow(2,n-2);

  }

}

// driver fuction

int main(){

  int n;

  cout << "Which element of the sequence would you like to know?\n";

cin >> n;

//checking for input less than 1

do{

   if(n<1)

   {

   cout<<"Please enter a  number greater than 0:"<<endl;

   cin>>n;

   }

}while(n<1);

//printing the output

cout<<n<<"th element of the sequence is: ";

cout << val(n);

}

Explanation:

in the given code, if user enter input less than 1 then it will again ask for the input greater than 0 . When the input is greater than 0,it calls the recursive function  with the parameter n .if the input is 1 then function will give 3 as output. And when input is greater than 1, the recursive function will return nth element of the given sequence.

output

which element of the sequence would you like to know?                                                                      

-1                                                                                                                          

Please enter a  number greater than 0:                                                                                      

0                                                                                                                          

Please enter a  number greater than 0:                                                                                      

5                                                                                                                          

5th element of the sequence is: 123

You might be interested in
What is a tax exemption (also known as a tax allowance)?
KengaRu [80]
<span>Tax exemption refers to a monetary exemption which reduces taxable income. Tax exempt status can provide complete relief from taxes, reduced rates, or tax on only a portion of items.</span>
4 0
3 years ago
Match the element of a presentation program to its description
lana [24]

Answer:

A) Array of buttons for<u> quick access </u>to commonly used <u>commands and tools</u>: Tool bar

That's what most people will use most of the time, to quickly perform the most common tasks.

B) <u>List of commands</u> to create, format and edit presentations: Menu Bar.

When the features listed in the tool bar aren't enough, we go to the Menu system, which lists all the features of the program.

C) <u>Provides info</u> about current slide<u> at the bottom</u> of the slide: Status Bar.

The status bar is always located at the <u>bottom of the screen</u>.

D) <u>Provides navigation</u> through the slides: Scroll bar.

Where you can scroll down and up your slides.

4 0
3 years ago
Declaring a variable in the method’s body with the same name as a parameter variable in the method header is ___________.
icang [17]

Answer:

a. a syntax error

Explanation:

When the same variable name is repeated in the parameter set and the method body, it will result in a syntax error. This is because the variable in the parameter has a local scope within the method body. Now if we declare another variable with the same name in the method body, it will result in redefinition of the variable and violate the uniqueness principle of variable names in the method code. This will give rise to syntax error.

8 0
3 years ago
Transaction processing systems (TPSs) provide valuable input to management information systems, decision support systems, and kn
nadezda [96]

A transaction is a simple task carried out as part of corporate operations. Transaction processing systems (TPS) handle business transactions for the corporation, supporting overall enterprise operations.

A TPS creates papers pertaining to a non-inquiry transaction and records the transaction itself, together with all of its results, in the database.

Today, TPS are required for business operations in practically every firm. TPSs feed information into organizational databases; they also serve as the framework for management-oriented information systems. Source data automation frequently involves direct data entering. Electronic data interchange is being utilized by transaction processing systems more and more. These systems offer computer-to-computer communication without the need for repeated data entry by substituting paper documents with formatted transaction data sent over telecommunications networks.

Learn more about information here-

brainly.com/question/15709585

#SPJ4

5 0
1 year ago
What's the drawback of using Screened Subnet (DMZ)?
lesantik [10]

It's more expensive, it's more difficult to configure and maintain and it can be more difficult to troubleshoot

4 0
3 years ago
Other questions:
  • The fast food restaurant Chipotle pulled its app from Apple's app store when customer demand caused the firm's servers to crash.
    14·1 answer
  • Chdtp aoxophg gr72 ae9&gt;3 zqqz
    12·1 answer
  • Which type of graph or chart will you use to show changes in data points?
    5·1 answer
  • Develop a C++ program that will determine whether a department store customer has exceeded the credit limit on a charge account.
    13·1 answer
  • In the Microsoft Excel spreadsheet how many choices are possible when using a single IF statement​
    9·1 answer
  • Which programming paradigm does the programming language JavaScript follow?
    14·1 answer
  • Will give brainliest
    10·1 answer
  • computer is an electronic machine that is used for data processing to produce meaningful information explain in statement​
    5·1 answer
  • Buying a home security system is an example of protecting your home against________.
    5·1 answer
  • **HELP ME PLS**
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!