Description
Explanation & Answer
Thank you for the opportunity to help you with your question!
a) crunch(5)=60
1st time it will go to else part = 5+crunch(5*10)
again crunch(50) function is executed
2nd time it will go to the else part= 5+ 50 +crunch(500)
again crunch(500) function is executed
since 500>100, it will return 500/100=5
total=5+50+5=60
b) crunch(-24)= will run for infinite times.
in the condition it is only if x>=100;
so every time it will go to the else part and get multiplied by 10, and still remain negative. hence it will not terminated.
precondition can be mod(x)>=100 will eliminate such errors.
Review
Review
24/7 Homework Help
Stuck on a homework question? Our verified tutors can answer all questions, from basic math to advanced rocket science!
Similar Content
Related Tags
Alice in Wonderland
by Lewis Carroll
Enders Game
by E. M. Forster
The Dispossessed
by Ursula Kroeber Le Guin
The Road
by Cormac McCarthy
Night
by Elie Wiesel
Into the Wild
by Jon Krakauer
Gone with the Wind
by Margaret Mitchell
The 48 Laws of Power
by Robert Greene
Sense And Sensibility
by Jane Austen