Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. The famous Fibonacci sequence f1, f2, f3, . . . is defined as f1 = 1, f2 = 1 fn = fn1 + fn2,

1. The famous Fibonacci sequence f1, f2, f3, . . . is defined as f1 = 1, f2 = 1 fn = fn1 + fn2, for n > 2 So the sequence begins as 1, 1, 2, 3, 5, 8, 13, 21, 34, . . .. Define a recursive function int fibonacci(int n) which returns the n-th Fibonacci number

2. Define recursive function my_sequence(n) which returns the n-th member of the sequence a1 = 3, a2 = 5, a3 = 7, an = an1 2an2 + an3, n > 3.

3. Define a recursive function double my_pow(double a, int n) which returns a n for integers n 0. Do not use library .

4.. It is not difficult to show that n i=1 1 i(i + 1) = 1 2 + 1 6 + 1 12 + . . . + 1 n(n + 1) = n n + 1 . So a simple C++ function which computes this sum is double f(int n) {return 1.0*n/(n+1); } Define a recursive function which computes this sum directly, without using the formula.

5.. Define recursive function void print_digits_reverse(unsigned int) which takes an unsigned int as input and prints its digits in reverse on the console (cout). (Hint: n/10 is the same as n with its ones digit removed.)

6.Define recursive function print_rectangle(m,n) which prints an mn grid of *s.

For example,

print_rectangle(4,3)

yields

***

***

***

***

7.Define function sequence(m,n) which prints the sequence of integers from m to n, counting up if m n, or counting down if m > n. For example, sequence(-1,3) prints

-1

0

1

2

3

while sequence(5,2) yields

5

4

3

2

USE C++ ONLY

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

a. How will the leader be selected?

Answered: 1 week ago

Question

b. Will new members be welcomed?

Answered: 1 week ago