Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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

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:

1, 1, 2, 3, 5, 8, 13,..... Fibonacci(0) and Fibonacci(1) are both 1. Fibonacci(2) is 2, Fibonacci(4) is 5 etc.

HERE IS THE SHELL

package h10;

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

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students explore these related Databases questions

Question

What are psychologys main subfields?

Answered: 3 weeks ago

Question

1.what is the significance of Taxonomy ?

Answered: 3 weeks ago

Question

Name is needed for identifying organisms ?

Answered: 3 weeks ago