Question: please help with 1b. 1. a. Write a recursive method octaldigitSum that takes a nonnegative integer parameter n and computes the sum of the digits

please help with 1b.please help with 1b. 1. a. Write a recursive method octaldigitSum that

1. a. Write a recursive method octaldigitSum that takes a nonnegative integer parameter n and computes the sum of the digits of n when represented as an octal (base 8 ) number. For example, octalDigitSum (14) is 7 , since the decimal number 14 is 16 in octal. octalDigitSum (39) is 11 . octaldigitSum (66) is 3. octaldigitSum (512) is 1. octalDigitSum (1) is 1, octalDigitSum (0) is 0. Hint: Use the fact that the sum of the (octal) digits of n is the sum of the last (octal) digit (the ones digit) of n plus the sum of the (octal) digits of n/8. Turn in your code (hard copy only). b. Prove by induction on the length of the octal representation of n that the method returns the sum of the (octal) digits of n. public class octaldecimalf public static void main(string[) args)f system,out.print(octalsum(39)); public static int octalsum(int decimal) int sum=0; if(decimal=0) feturn sum; elsef sum +E decimals8 + octalsum(decimal/8); , return sum

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!