Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2) Sequence length Define the functions f as follows: f(n)=(n+1)/23n+12n+3ifnisoddifnisamultipleof4ifnisevenbutnotamultipleof4 Let Sf(n) be the longest sequence without repetition of entries, obtained by starting from n

image text in transcribed

2) Sequence length Define the functions f as follows: f(n)=(n+1)/23n+12n+3ifnisoddifnisamultipleof4ifnisevenbutnotamultipleof4 Let Sf(n) be the longest sequence without repetition of entries, obtained by starting from n and iteratively applying f. For example Sf(3)=(23,12,37,19,10) because f(23)=12,f(12)= 37,f(37)=19,f(19)=10. We have to stop at 10 because f(10)=23 and it will lead to a repetition. i) Write a SAGE function LongSfn(n) that returns the length (number of entries) of the longest of the sequences Sf(1),Sf(2),,Sf(n). For example, Since Sf(1)=(1),Sf(2)=(2,7,4,13) and Sf(3)=(3,2,7,4,13),LongSfn(3) must return 5 . ii) Plot LongSfn(n) for n{1,2,,50}

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

More Books

Students also viewed these Databases questions