Question: java coding Write a recursive method body for the smallestDigit method whose contract is given below. As an example, if n - 23141, the method
Write a recursive method body for the smallestDigit method whose contract is given below. As an example, if n - 23141, the method should return 1. You may only use NaturalNumberkernel methods: multiplyBy 10, divideBy 10, and isZero. (see API doc) Do not restore the parameter n by making a copy. Do not use magic numbers, breaks or multiple returns./** * Reports the minimum (i.e., smallest) single digit in n when it * is written in ordinary decimal notation. * ... * @ ensures * smallestDigit = the smallest digits in n] */private static int smallestDigit (NaturalNumber n)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
