Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java programming 1) a) write the recursive function int digitSum (int n), which gets the positive integer n and returns the sum of individual digits
Java programming 1) a) write the recursive function int digitSum (int n), which gets the positive integer n and returns the sum of individual digits in it. For example, if called by the digitSum (234), it returns 9 (= 2 + 3 + 4). Note that if n is an integer, n% 10 returns the first digit to n (234% 10 is 4) and that n / 10 takes away the last digit in n (234/10 is 23). Also write a short main case that tests your function. b) The first numbers in the Threebonacci series are 0, 0, 1, 1, 2, 4, 7, 13, 24, ... Write two functions to calculate the n Threebonacci numberone recursive (tribRec (int n), but the other not recursive (tribo (int n). Also write a main-case that receives one positive integer of the command line, calling both functions and prints the result. Please write the full code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started