Question: Exercise 1: These are recursive programs discussed in the lectures. a) Factorial of an integer n if n > 0, then factorial(n)- n * factorial(n-1)

 Exercise 1: These are recursive programs discussed in the lectures. a)Factorial of an integer n if n > 0, then factorial(n)- n

Exercise 1: These are recursive programs discussed in the lectures. a) Factorial of an integer n if n > 0, then factorial(n)- n * factorial(n-1) Write a recursive method public static int factorial(int n) that finds factorial of a non-negative if n 0, then factorial(n) 1 integer n. Use this method in the main method to print the factorials of 1 to 10. b) Fibonacci series 0,1,1,2,3.5,8,13,21,34.. ifn-0, then fib(n)-0 //base case ifn-1, then fib(n)-1 //base case if n>1, then fib(n) - fib(n-1)+ fib(n-2) Write a recursive method public static int fib(int n) that finds the nth number in the Fibonacci series

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!