Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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_2

Step: 3

blur-text-image_3

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

Mastering Big Data Interview 751 Comprehensive Questions And Expert Answers

Authors: Mr Bhanu Pratap Mahato

1st Edition

B0CLNT3NVD, 979-8865047216

More Books

Students also viewed these Databases questions

Question

Employ effective vocal cues Employ effective visual cues

Answered: 1 week ago