Explanation of Solution
Modified function for “MysteryWrite” function:
The modified function for “MysteryWrite” function is shown below:
#Function definition for "MysteryWrite"
def MysteryWrite(Last, Current):
#Check the value of variable "Current"
if(Current < 100):
#Add the value of "Current" and "Last" and store it variable "Temp"
Temp = Current + Last
#Call "MysteryWrite" function with arguments "Current" and "Temp"
MysteryWrite(Current, Temp)
#Display the numbers in reverse order
print(Current)
#Display the message
print('Reverse order')
#Call "MysteryWrite" function with the value for "Current" is "0" and "Last" is "1"
MysteryWrite(0,1)
Explanation:
The above code is used to print the sequence of numbers in reverse order using “MysteryWrite”
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Computer Science: An Overview (12th Edition)
- (Program) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters, such as zerocount, onecount, twocount, and so forth, to 0. Then generate a large number of pseudorandom integers between 0 and 9. Each time 0 occurs, increment zerocount; when 1 occurs, increment onecount; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of time they occurred.arrow_forwardThe MATLAB function arg supports variable arguments, returns the sum of the number of arguments and all arguments, and has a help function. Write the arg so that the next execution results. >> help argIt supports variable arguments. >> [n,m] = arg(5,6)n = 2m = 11>> [n, m] = arg(3,4,5)n = 3m = 12arrow_forwardInstead of using the * operator (or the / operator), create a recursive function that multiplies two positive integers. Bit shifting, addition, and subtraction are all acceptable, but you should use them sparingly.arrow_forward
- Write a function sumDigits, that accepts a positive integer n and returns the sum of the digits in that integer; thus, sumDigits(34) would return 7 (e.g., 3+4). Use the techniques from the roman numeral problem to extract the digitsarrow_forwardfor C++ write a progam for the greatest common divisor of integers x and y is the largest integer that evenly divides both x and y. Write a recursive function gcd that returns the greatest common divisor of x and y. The gcd of x and y is defined recursively as follows. If y is 0 the answer is x; otherwise gcd(x, y) is gcd(y, x%y).arrow_forwardc++ Write a recursive function that, given two strings, returns whether the first string is asubsequence of the second. For example, given hac and cathartic, you should return true, but givenbat and table, you should return false.arrow_forward
- Write a Recursive Function to print number from Given input down to 0?arrow_forwardRefine the is_palindrome function to work with arbitrary strings, by ignoring non-letter characters and the distinction between upper- and lowercase letters. For example, if the input string is "Madam, I’m Adam!" then you’d first strip off the last character because it isn’t a letter, and recursively check whether the shorter string "Madam, I’m Adam" is a palindrome. c++arrow_forwardWrite a recursive function, vowels, that returns the number of vowels in a string. Also, write a program to test your function.arrow_forward
- Write a function repeatPhrase(phrase, n), which prints the given phrase n times, alternating between lowercase and uppercase. Recall, that if a String is a string, then a.upper() is the uppercase of that string, and a.lower() is the lower case of the string. For example, repeat('The sky is yellow', 5) would print: the sky is yellowTHE SKY IS YELLOW the sky is yellowTHE SKY IS YELLOW the sky is yellowarrow_forwardWrite a recursive function in f#, named specialSum, that has the followeing signature: int * int -> int, where sum(m,n) = m + (m +1) + (m+2) + ... + (m + (n-1)) + (m+n) for m >= 0 and n >= 0: (Hint use two clauses with (m,0) and (m,n) A PATTERNS.) start code with let rec specialSum (m,n) match m,n with | m,0 -> | m,n - >arrow_forwardSolve by using C language and by using functions Write a program that uses six calls to the function rand() to generate six randominteger numbers, num1, num2, num3, num4, num5, and num6, and then print them out.num1 should be in the range 1 to 2 (inclusive), num2 should be in the range 1 to 100 (inclusive),num3 should be in the range 0 to 9, num4 should be in the range 1000 to 1112 (inclusive),num5 should be in the range -1 to 1, and num 6 should be in the range -3 to 11.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning