The following iterative sequence is defined for the set of positive integers: Sn/2 if n is even Un = 3n +1 if n is odd Using the rule above and starting with 13, we generate the following sequence: 13 u13 = 40 u40 = 20 → u20 = 10 → u10 = 5→ Uz = 16 → u16 =8 ug =4 U4 = 2 u2 = 1. It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. The below function takes as input an integer n and returns the number of terms generated by the sequence starting at n. function i-Seq (n) %3D %3D %3D %3D %3D %3D u=n3; i-%3B while u -1 if statement 1 u=u/2; else statement 2 end i=i+1; end statement 1 and statement 2 should be replaced by: None of the choices statement 1 is "mod(u,2)=D%30" and statement 2 is "u = 3*u+1;" statement 1 is "u%2" and statement 2 is "u = 3*u+1;" O statement 1 is "mod(n,2)=30" and statement 2 is "u = 3*n+1;"

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter3: Data Representation
Section: Chapter Questions
Problem 13VE: A(n) __________ contains 8 __________.
icon
Related questions
Question
le.com/forms/d/e/1FAlpQLSc6PlhZGOLJ4LOHo5cCGEf9HDChfQ-tT1bES-BKgkKu44eEnw/formResponse
The following iterative sequence is defined for the set of positive integers:
Sn/2
3n +1 ifn is odd
if n is even
Un =
Using the rule above and starting with 13, we generate the following sequence:
13 u13 = 40 u40 =20 u20 = 10→ u10 =5 u5 = 16 u16 = 8 ug = 4 →
Us =2 u2 =1.
It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms.
The below function takes as input an integer n and returns the number of terms
generated by the sequence starting at n.
function i-Seq (n)
u=n;
i=%3;
while u =1
if statement 1
u=u/2;
else
statement 2
end
i=i+1;
end
statement 1 and statement 2 should be replaced by:
None of the choices
statement 1 is "mod(u,2)=D%3D0" and statement 2 is "u = 3*u+1;"
statement 1 is "u%2" and statement 2 is "u = 3*u+1;"
O statement 1 is "mod(n,2)=30" and statement 2 is "u = 3*n+1;"
Transcribed Image Text:le.com/forms/d/e/1FAlpQLSc6PlhZGOLJ4LOHo5cCGEf9HDChfQ-tT1bES-BKgkKu44eEnw/formResponse The following iterative sequence is defined for the set of positive integers: Sn/2 3n +1 ifn is odd if n is even Un = Using the rule above and starting with 13, we generate the following sequence: 13 u13 = 40 u40 =20 u20 = 10→ u10 =5 u5 = 16 u16 = 8 ug = 4 → Us =2 u2 =1. It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. The below function takes as input an integer n and returns the number of terms generated by the sequence starting at n. function i-Seq (n) u=n; i=%3; while u =1 if statement 1 u=u/2; else statement 2 end i=i+1; end statement 1 and statement 2 should be replaced by: None of the choices statement 1 is "mod(u,2)=D%3D0" and statement 2 is "u = 3*u+1;" statement 1 is "u%2" and statement 2 is "u = 3*u+1;" O statement 1 is "mod(n,2)=30" and statement 2 is "u = 3*n+1;"
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Binary numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning