The following iterative sequence is defined for the set of positive integers: ifn is even 3n +1 ifnis odd Using the rule above and starting with 13, we generate the following sequence: 20 u20 = 10 →...


The following iterative sequence is defined for the set of positive integers:<br>ifn is even<br>3n +1 ifnis odd<br>Using the rule above and starting with 13, we generate the following sequence:<br>20 u20 = 10 → U10 = 5 U5 = 16 u16 =8us = 4-<br>13 u13 40 u40=<br>u=2 u2 = 1.<br>It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms.<br>The below function takes as input an integer n and returns the number of terms<br>generated by the sequence starting at n.<br>function i-Seq (n)<br>u-n;<br>1=1%B<br>while u -1<br>if statement 1<br>u-u/2%3;<br>else<br>statement 2<br>end<br>1=i+1%3B<br>end<br>statement 1 and statemet 2 should e replacerd bv:<br>statement 1 is 'mod(n.2)=30 and statement 2 is 'u - 3*n+1;

Extracted text: The following iterative sequence is defined for the set of positive integers: ifn is even 3n +1 ifnis odd Using the rule above and starting with 13, we generate the following sequence: 20 u20 = 10 → U10 = 5 U5 = 16 u16 =8us = 4- 13 u13 40 u40= u=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; 1=1%B while u -1 if statement 1 u-u/2%3; else statement 2 end 1=i+1%3B end statement 1 and statemet 2 should e replacerd bv: statement 1 is 'mod(n.2)=30 and statement 2 is 'u - 3*n+1;" O None of the choices KO statement 1 is u%2 and statement 2 is u= 3*u+1;" O statement 1 is mod(u.2)==0 and statement 2 is u= 3*u+1," op

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here