#### Question:

A class **Recursion** has been defined to find the Fibonacci series upto a limit. Some of the members of the class are given below:

**Class Name :** Recursion

**Data Members/instance variables :** a, b, c, limit (all integers)

**Member functions/methods :**

**Recursion() :** constructor to assign a,b,c with appropriate values.

**void input() :** to accept the limit of the series.

**int fib(int n) :** to return the **nth** Fibonacci term using** recursive technique**.

**void genearate_fibseries() :** to generate the Fibonacci series upto the given limit.

Specify the class **Recursion** giving details of the **constructor**, **int fib()** , **void generate_fibseries()**. You may assume other functions are written for you and you need not write the main function.

#### Programming Code:

/** * The class Recursion prints the Fibonacci Series upto 'n' terms using the concept of Recursion * @author : www.javaforschool.com * @Program Type : BlueJ Program - Java * @Question Year : ISC Theory 2005 Question 12 */ import java.io.*; class Recursion { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int a,b,c,limit; Recursion() //Constructor { a=0; b=1; c=0; limit=0; } void input()throws IOException //Function to input the limit { System.out.print("Enter the limit : "); limit=Integer.parseInt(br.readLine()); } int fib(int n) //Recursive function generating the 'nth' term of Fibonacci Series { if(n<=1) return a; else if(n==2) return b; else return (fib(n-1)+fib(n-2)); } void generate_fibseries() //Function generating all the Fibonacci Series numbers upto 'n' terms { System.out.println("The Fibonacci Series is:"); for(int i=1;i<=limit;i++) { c=fib(i); System.out.print(c+" "); } } public static void main(String args[])throws IOException { Recursion ob=new Recursion(); ob.input(); ob.generate_fibseries(); } }

#### Output:

Enter the limit : 11

The Fibonacci Series is:

0 1 1 2 3 5 8 13 21 34 55

Enter the limit : 20

The Fibonacci Series is:

0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181

nice program…

can you please write the programs for factorial and gcd of a number using recursion

Kindly go through these : http://www.guideforschool.com/372-collection-of-number-based-programs-using-recursion-isc-computer-science/

and

http://www.guideforschool.com/345-collection-of-string-programs-using-recursion-isc-computer-science/

I am very much glad as I have got maximum answers from this websites regarding programs.

I am very happy to visit this website and get the answers.