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).

ka1leE

ka1leE

Answered question

2020-12-31

Consider the following pseudocode function. function Crunch(x isR)ifx100 then return x/100 else return x+Crunch(10x) Compute Crunch(117).

Answer & Explanation

liannemdh

liannemdh

Skilled2021-01-01Added 106 answers

Solution:
Crunch (x is in R)
if x100 then
Return x100
else return x+Crunch (10x)
We need to compute Crunch (117)
x=117
Since 117 is at least 100, we need to execute the then-statement "return x100" as a result, we must divide the input x=117 by 100:
x100=117100=1.17
Therefore, Crunch (117)=1.17

Do you have a similar question?

Recalculate according to your conditions!

New Questions in Discrete math

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?