Question

The formula for the nth Tetranacci number ?? is defined as follows: ?0 = 0 ?1...

The formula for the nth Tetranacci number ?? is defined as follows: ?0 = 0 ?1 = 1 ?2 = 1 ?3 = 2 ?? = ??−1 + ??−2 + ??−3 + ??−4 Your task is to implement a recursive function which accepts an integer n (you may assume that n >= 0), and computes the n-th Tetranacci number (don’t worry about efficiency, only about making the definition as simple as possible).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: If you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

#include <stdio.h>
int tera(int n)
{
if(n==0)
return 0;
if(n==1)
return 1;
if(n==2)
return 1;
if(n==3)
return 2;
return tera(n-1)+tera(n-2)+tera(n-3)+tera(n-4);
}

int main()
{
printf("%d\n",tera(8));

return 0;
}

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
The formula for the nth Tetranacci number ?? is defined as follows: ?0 = 0 ?1...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In mathematics, the Nth harmonic number is defined to be 1 1/2 1/3+ 141/N. So, the...

    In mathematics, the Nth harmonic number is defined to be 1 1/2 1/3+ 141/N. So, the first harmonic number is 1 second is 1.5, the third is 1.83333... and so on. Assume that n is an integer variable whose value is some also that hn is a double variable whose value is the Nth harmonic number. Write an expression whose value is the (N+-1)th , the harmonic number.

  • Suppose that a Tibonacci sequence is defined as follows: Tibo(0) = 1, Tibo(1) = 2, Tibo(2)...

    Suppose that a Tibonacci sequence is defined as follows: Tibo(0) = 1, Tibo(1) = 2, Tibo(2) = 3 Tibo(n) = Tibo(n-1) + Tibo(n-3), when n ≥ 3 Write a recursive method Tibo, that takes some integer n as a parameter and returns the n-th Tibonacci number. You DO NOT need to write the main function.

  • Consider Fibonacci number F(N), where N is a positive integer, defined as follows. F(1) = 1...

    Consider Fibonacci number F(N), where N is a positive integer, defined as follows. F(1) = 1 F(2) = 1 F(N) = F(N-1) + F(N-2) for N > 2 a) Write a recursive function that computes Fibonacci number for a given integer N≥ 1. b) Prove the following theorem using induction: F(N) < ΦN for integer N≥ 1, where Φ = (1+√5)/2.

  • IN JAVA A Fibonacci Word is a string of 0's and 1's defined recursively as follows:...

    IN JAVA A Fibonacci Word is a string of 0's and 1's defined recursively as follows: So ) = "0" S1 = "01" Sn Sn-1 Concatenated with Sn-2 Write a recursive method that computes the nth Fibonacci word and have your main method illustrate its use

  • Write a program in MIPs Assembly Language to compute nth number of a fibonacci number sequence....

    Write a program in MIPs Assembly Language to compute nth number of a fibonacci number sequence. Your program should prompt for an integer input n from the user. The program should call a recursive function to compute the nth fibonacci number. Your program must follow programming convention. You should submit program and screenshot of output in a single word/pdf file. You should use following recursive definition of fibonacci function: fib(0) = 0 fib(1) = 1 fib(n) = fib(n-1) +fib(n-2)

  • F# ONLY SOMEONE SOLVED IN PYTHON JUST NOW. I NEED F SHARP PROGRAMMING THANKS A more...

    F# ONLY SOMEONE SOLVED IN PYTHON JUST NOW. I NEED F SHARP PROGRAMMING THANKS A more efficient version of the function for computing Tetranacci numbers can be defined by following three steps: Implement a function which takes a list of integers and adds the sum of the top four elements to the head of the list (e.g., in F#, 1::1::1::1::[] should become 4::1::1::1::1::[]). Implement a recursive function which accepts an integer n as input (again, assume n >= 0), and...

  • 1. The famous Fibonacci sequence f1, f2, f3, . . . is defined as f1 =...

    1. The famous Fibonacci sequence f1, f2, f3, . . . is defined as f1 = 1, f2 = 1 fn = fn−1 + fn−2, 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 =...

  • Using java programming. Question 1. Write a recursive function fibo(n) that returns the nth Fibonacci number...

    Using java programming. Question 1. Write a recursive function fibo(n) that returns the nth Fibonacci number which is defined as follows: fibo(0) = 0 fibo(1) = 1 fibo(n) = fibo(n-1) + fibo(n-2) for n >= 2 Question 2. Write a recursive function that calculates the sum of quintics: 1power of5 + 2power of5 + 3power of5 + … + n5 Question 3. Write a program to find a route from one given position to another given position for the knight...

  • 1. Write an iterative C++ function that inputs a nonnegative integer n and returns the nth...

    1. Write an iterative C++ function that inputs a nonnegative integer n and returns the nth Fibonacci number. 2. Write a recursive C++ function that inputs a nonnegative integer n and returns the nth Fibonacci number.

  • The factorial of a nonnegative n written as n! is defined as follows: n!= n*(n-1)*(n-2) *...

    The factorial of a nonnegative n written as n! is defined as follows: n!= n*(n-1)*(n-2) * .... *1 (for all values of n greater than 0) and 0! =1. For example 5! = 5*4*3*2*1 which is 120. (can also be 1*2*3*4*5) Write a C++ program that reads a nonnegative integer and computes and prints its factorial.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT