Question: Consider the function f ( n ) = n 2 if n is even 3 n + 1 if n is odd Given an initial
Consider the function
fn n
if n is even
n if n is odd
Given an initial value for n an integer we set a n and ai fai The stopping
value of n is the first i such that ai The escape value of n is the first i such that
ai
For example, if n then
a a a a a a
and so the stopping number is and there is no escape value.
Write a function called outcome which takes as input integers n and max. If either n or max
are less than it should return Please pick strictly positive integers Otherwise it should
return either the stopping value of n or the escape value of n whichever happens first or
the message The process did not terminate within max stepswhere max is the number
entered as the second input value
You should use the Mod function in VBA you may need to look this up online and a suitable
Do While loop. Declare all variable types and include appropriate comments in your code.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
