Question

Write C code for this, using pico text editor

3. A sequence an is given with the following rule: an+2 a1 =-1 Write a C program to compute a17

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

#include<stdio.h>
//given
//a(n+2) = -2*a(n+1)+3*a(n)
//a(n) = -2*a(n-1)+3*a(n-2) // both are equivallent...
int a(int n)// function that finds a17
{
   if(n==0)
   return 2;/// for a0 value is 2
   if(n==1)
   return -1;// for a1 value is -1
  
   return -2*a(n-1)+3*a(n-2);//recursive call
}

int main()
{
   int n =17;
  
   int c = a(17);//finging a17 value by function calling
  
   printf("%d\n",c);//printing result...
  
  
   return 0;
}

output:

-96855121


Process exited normally.
Press any key to continue . . .

Add a comment
Know the answer?
Add Answer to:
Write C code for this, using pico text editor 3. A sequence an is given with...
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
  • Python: Using your favorite text editor, write a program that outputs the string representation of numbers...

    Python: Using your favorite text editor, write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”. Submit by uploading a .py file Example: n = 15, Return: [ "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz"...

  • GOALI Using your text editor, write the function sumSquares(aList). The function takes a list as ninput...

    GOALI Using your text editor, write the function sumSquares(aList). The function takes a list as ninput and returns (not prints) the sum of the squares of the all the numbers which absolute value s divisible by 3. If an element in the list is not a number, the function should ignore the value and ontinue. When the function receives an input that is not a list, code should return an error message o the user. Hints: review the type) or...

  • write the solution of the program by python 3 language : I need the program using...

    write the solution of the program by python 3 language : I need the program using list : You are given a sequence of n positive integers a1,a2,…,an, where n is even. Swap adjacent elements in the given sequence and print the resulting sequence: a2,a1,a4,a3,a6,a5,… Input The first line contains a positive even integer n (2≤n≤1000) — the length of the sequence. The second line contains n space-separated integers a1,a2,…,an (1≤ai≤1000) — the elements of the sequence. Output Print n...

  • in C language 1. Create a data file called superheroes.dat using any text-based editor, and enter...

    in C language 1. Create a data file called superheroes.dat using any text-based editor, and enter at least three records storing superheros' names and main superpower. Make sure that each field in the record is separated by a space. 2. Using the superheroes.dat file from problem 1, build another program that uses the fscanf() function for reading each record and printing field information to standard output until the end-of-file is reached. Include an error handling routine that notifies the user...

  • Using R code only 4. The Fibonacci numbers are the sequence of numbers defined by the...

    Using R code only 4. The Fibonacci numbers are the sequence of numbers defined by the linear recurrence equation Fn F-1 F-2 where F F2 1 and by convention Fo 0. For example, the first 8 Fibonacci numbers are 1, 1, 2, 3, 5, 8, 13, 21. (a) For a given n, compute the nth Fibonnaci number using a for loop (b) For a given n, compute the nth Fibonnaci number using a while loop Print the 15th Fibonacci number...

  • Please write the code in a text editor and explain thank you! 1. LINKED-LIST: Implement a...

    Please write the code in a text editor and explain thank you! 1. LINKED-LIST: Implement a function that finds if a given value is present in a linked-list. The function should look for the first occurrence of the value and return a true if the value is present or false if it is not present in the list. Your code should work on a linked-list of any size including an empty list. Your solution must be RECURSIVE. Non-recursive solutions will...

  • Hi, I need help for solving Linux question. . 1.Using the proper text editor, create a...

    Hi, I need help for solving Linux question. . 1.Using the proper text editor, create a shell file called by (your name), your enrollment number, your program and the courses you study. Use the appropriate variables and display the above to the standard output (screen). . 2. Write A Shell Script to perform the following: Display the files and directories Print the date in 24 hour format Display the System id Display the current working directory Print the status of...

  • Write the Python Function program to find the RRi of Given Protein Sequence. input: Two inputs...

    Write the Python Function program to find the RRi of Given Protein Sequence. input: Two inputs will be one is Sequence and the other is Amino Acid. Output: RRi Example: Here input is a different sequence and Amino acid is "A". Code Example : def Function(Sequence,AminoAcide): # Your Code This means for a given residue type, minimum RRI will be 1 and maximum will be total number of that type of residues in sequence. This value measures multiple runs of...

  • write the solution of the program by python 3 language : I need the program using...

    write the solution of the program by python 3 language : I need the program using list : You are given a non-decreasing sequence of n positive integers a1,a2,…,an. Print the number of distinct values in the sequence. For example, if the sequence is 1,2,2,2,3,4,4,5,7,10, the answer is 6 since distinct values are 1,2,3,4,5,7,10. Input The first line contains a positive integer n (1≤n≤1000) — the length of the sequence. The second line contains n space-separated positive integers a1,a2,…,an (1≤ai≤1000)...

  • write the solution of the program by python 3 language : I need the program using...

    write the solution of the program by python 3 language : I need the program using list or string or loops (while and for) or if,elif,else : You are given a sequence of n non-zero integers a1,a2,…,an. Determine if the given sequence contains a pair of adjacent elements of the same sign (both negative or both positive). Two elements are called adjacent if they stand next to each other in the sequence. Input The first line contains an integer n...

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
ADVERTISEMENT