Question: Using NetBeans, create a program to test the recursive and non-recursive methods for factorial and Fibonacci. Here is a driver, you can just add your

Using NetBeans, create a program to test the recursive and non-recursive methods for factorial and Fibonacci.

Here is a driver, you can just add your methods to the java file in this project. H10 Shell.zip Download H10 Shell.zip

A recursive method is one that calls itself. Your recursive methods will not need a loop.

A non-recursive method doesn't call itself, and in this assignment your non-recursive methods will need a loop.

For factorial, whether recursive or not, the smallest possible value of n should be zero , and 0! (factorial zero) = 1.

Fibonacci(n) is the nth Fibonacci number. The Fibonacci sequence is this:

0, 1, 1, 2, 3, 5, 8, 13,..... Here Fibonacci(6) = 8, Fibonacci(7) = 13.

public class H10 {

public static void main(String[] args) { System.out.println("Non recursive Factorial"); for (int i=0; i<=10; i++) System.out.println("Factorial " + i + " equals " + factorial(i)); System.out.println(); System.out.println("Recursive Factorial"); for (int i=0; i<=10; i++) System.out.println("Factorial " + i + " equals " + recFactorial(i)); System.out.println(); System.out.println("Non recursive Fibonacci"); for (int i=0; i<=10; i++) System.out.println("The " + i + "th Fibonacci number is " + fibonacci(i)); System.out.println(); System.out.println("Recursive Fibonacci"); for (int i=0; i<=10; i++) System.out.println("The " + i + "th Fibonacci number is " + recFibonacci(i)); }//main

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!