Consider the following pseudocode function. function Crunch(x is in R) if x ≥ 100 then return x/100 else return x + Crunch(10 · x) Compute Crunch(117).

Question
Discrete math
asked 2020-12-31
Consider the following pseudocode function. function Crunch\(\displaystyle{\left({x}{i}{s}\in{R}\right)}{\quad\text{if}\quad}{x}≥{100}\) then return x/100 else return x + Crunch(10 · x) Compute Crunch(117).

Answers (1)

2021-01-01
Given
Crunch (x is in R)
if \(\displaystyle{x}\Rightarrow{100}\) then
returen \(\displaystyle\frac{{x}}{{100}}\)
else return x+Crunch \(\displaystyle{\left({10}\cdot{x}\right)}\)
We need to compute Crunch(117)
x=117
Since 117 is at least 100, we need to execute the then-statement "return \(\displaystyle\frac{{x}}{{100}}\)" and thus we need to divide the input x=117 by 100:
\(\displaystyle\frac{{x}}{{100}}=\frac{{117}}{{100}}={1.17}\)
Thus Crunch(117)=1.17
0

Relevant Questions

asked 2021-03-11
Factor \(\displaystyle{f{{\left({x}\right)}}}={2}{x}^{{{3}}}+{\left(-{3}-{2}{i}\right)}{x}^{{{2}}}+{\left(-{3}-{i}\right)}{x}+{\left({2}+{i}\right)}\) into linear factors if \(\displaystyle{2}+{i}\) is a zero of the function.
asked 2021-03-11
The following problem is solved by using factors and multiples and features the strategies of guessing and checking and making an organized list.
Problem
A factory uses machines to sort cards into piles. On one occasion a machine operator obtained the following curious result.
When a box of cards was sorted into 7 equal groups, there were 6 cards left over, when the box of cards was sorted into 5 equal groups, there were 4 left over, and when it was sorted into 3 equal groups, there were 2 left.
If the machine cannot sort more than 200 cards at a time, how many cards were in the box?
asked 2020-12-03
MODULAR ARITHMATICS
Find two numbers a and b bewen 50 and 100 saticfies these conditions:
-The greatest common divisor of a and b is \(\displaystyle{3}{\left({\gcd{{\left({a},{b}\right)}}}={3}\right)}\)
-The difference \(\displaystyle{b}-{a}\geq{25}\)
Preform Euclids algotirhm on these two numbers. Find whole numbers x and y such that \(\displaystyle{3}={a}{x}+{b}{y}\)
asked 2021-03-02
Using cardinatility of sets in discrete mathematics the value of N is real numbers Currently using elements of discrete mathematics by Richard Hammack chapter 18 Let A be a collection of sets such that X in A if and only if \(X \supset N\ \text{and} |X| = n\) for some n in N. Prove that \(|A| = |N|\).
asked 2020-11-03
Let the universal set the set of R of all real numbers and
Let \(A={x in R|-1
a:find \(A cup B\)
b:Find \(A cap B\)
c:Find \(A^c\)
asked 2021-02-09
Consider the following recurrence relation:
\(\displaystyle{a}_{{n}}={2}\cdot{a}_{{{n}-{1}}}-{3}\ \text{with}\ {a}_{{1}}={5}\)
asked 2020-11-17
Make fractions out of the following information, reduce, if possible,
1 foot is divided into 12 inches. Make a fraction of the distance from 0 to a-d
0 to a. = ___
0 to b. = ___
0 to c. = ___
0 to d. = ___
asked 2020-11-10
For the following, write your list in increasing order, separated by commas.
a, List the first 10 multiples of 8.
b. LIst the first 10 multiples on 12.
c. Of the lists you produced in parts a. and b., list the multiples that 8 and 12 have in common.
d. From part c., what is the smallest multiple that 8 and 12 have in common.
asked 2021-02-01
Prove or disaprove that if a|bc, where a, b, and c are positive integers and \(\displaystyle{a}≠{0}{a}\), then a|b or a|c.
asked 2021-01-31
Use symbols to write the logical form of the following arguments. If valid, iden- tify the rule of inference that guarantees its validity. Otherwise, state whether the converse or the inverse error has been made. If you study hard for your discrete math final you will get an A. Jane got an A on her discrete math final. ‘Therefore, Jane must have studied hard.
...