Question: In python Consider the two sequences P according to the formulas: [1,1,1] and O-[3,0,2]. Suppose that these sequences are extended P(n+1)-P(n-1+P(n-2) (n1)-9(n-1)+0(n-2) That is, for

 In python Consider the two sequences P according to the formulas:

In python

Consider the two sequences P according to the formulas: [1,1,1] and O-[3,0,2]. Suppose that these sequences are extended P(n+1)-P(n-1+P(n-2) (n1)-9(n-1)+0(n-2) That is, for both P and Q you ignore the most recent value, then add up the next two most recent The first 8 values of each sequence are: P [11.2,2,3,4,5. O- [3,0,2,3,2,5,5,7..] 1. Create a function provide P(n) that returns a list of all values in Psn. Repeat for O in a function provide On) Call each function to generate lists P and O forn 10,000. Use the concept of a set with these lists to determine the following 2. a. How many unique integers are in P? How many unique integers are in O? b. How many integers occur in both P and O? c. How many prime integers occur in both P and ? (Compare to a list of primes recall the Sieve of Eratosthenes.) d. There is only one number that exists in both P and Q that is not a prime. What i:s it? (Don't just inspect your answer to (c); work it out explicitly in code.) Hint: Once you've defined your functions, you should only need a few lines of code to answer this entire problem. Consider the two sequences P according to the formulas: [1,1,1] and O-[3,0,2]. Suppose that these sequences are extended P(n+1)-P(n-1+P(n-2) (n1)-9(n-1)+0(n-2) That is, for both P and Q you ignore the most recent value, then add up the next two most recent The first 8 values of each sequence are: P [11.2,2,3,4,5. O- [3,0,2,3,2,5,5,7..] 1. Create a function provide P(n) that returns a list of all values in Psn. Repeat for O in a function provide On) Call each function to generate lists P and O forn 10,000. Use the concept of a set with these lists to determine the following 2. a. How many unique integers are in P? How many unique integers are in O? b. How many integers occur in both P and O? c. How many prime integers occur in both P and ? (Compare to a list of primes recall the Sieve of Eratosthenes.) d. There is only one number that exists in both P and Q that is not a prime. What i:s it? (Don't just inspect your answer to (c); work it out explicitly in code.) Hint: Once you've defined your functions, you should only need a few lines of code to answer this entire

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!