Java Code to Compute Fibonacci Series using Recursion for N Terms.

/* Fibonacci Numbers are 1, 1, 2, 3, 5, 8, 13, 21, 34…. which can be calculated by the formula fn=fn-1+fn-2 where f1=1, f2=1.
Fibonacci series is a sequence of numbers defined by f1 = 1 f2 = 1 fn=fn-1+fn-2The following code prints Fibonacci series for N terms (Fibo(n)) using recursion . */

import java.io.*;

public class FiboSeries
{
public static void main(String[] args)
{

System.out.println(“Enter the no of terms the Fibonacci Series to be generated”);

try
{
BufferedReader br=new BufferedReader (new InputStreamReader(System.in));

int n = Integer.parseInt(br.readLine());

System.out.println(“Fibonacci Series upto “+ n + ” Terms”);
for (int i = 1; i <= n; i++)
{
int f = fibo(i);
System.out.print(f +” “);
}
}

catch (Exception e)
{
System.out.println(“Error”);
}

System.exit(0);
}

//to find nth Fibonacci number
public static int fibo(int n)
{
if (n <= 2)
return 1;
else
return fibo(n – 1) + fibo(n – 2);
}
}

Output of the Above Program
———————————-
Enter the no of terms the Fibonacci Series to be generated
10
Fibonacci Series upto 10 Terms
1 1 2 3 5 8 13 21 34 55

Leave a Reply

ohio cbd law cbd and hashimotos treatibles cbd oil drops reviews cbd dietary supplement fda cbd health solutions tram to melbourne zoo from cbd cbd in tea what is cbd terpenes cbd good for skin cbd vapor oil in greenwood high cbd low thc weed bocannaco cbd where can i buy cbd cream best cbd oil for fibromyalgia side effects of cbd cream cbd panacea cbd quick facts cbd in north carolina transdermal cbd oil does cbd oil work for vulvodynia dr axe cbd oil price cbd and bone healing 125 mg cbd oil charlottes webb cbd oil charly jordan cbd oil cbd oil metabolism bluebird classic cbd oil cbd honey cannabis oil making best way to smoke cbd oil

legitimate penile enlargement off counter sexual enhancement male enhancement distributors does nitric oxide supplements work foods male libido enhancement pills to make penis work liquor for male enhancement male enhancement instant schwinn male enhancement review blue pills knock out drug for sex garunteed penis enlargement penis enlargement excercis ed pills walmart male penis enhancement techniques chinese diet pills traveling through airport with sex pills alcar supplements for ed best l citrulline supplement extenze pill side effects ed pills no prescription fastgrow penis enlargement low dose birth control pills libido ayurvedic medicine for sexual health natural male enhancement herbal n02 supplements do otc ed pills work nitro supplement sex 54612 pill jym supplements reviews 3x male enhancement

keto weight loss pills megan kelly weight loss pills weight loss with pills diet for bodybuilding weight loss keto diet side dishes recipes vegan diet for weight loss fast keto diet recipes filetypepdf ways to boost weight loss with diet and exercise best diet to lose weight fast in a week dash diet weight loss plan why can i only lose weight on a low carb diet why does gluten free diet cause weight loss green smoothie diet weight loss results adrenalize weight loss pills weight loss surgery pre diet sardine diet for weight loss ketogenic diets microbiome diet weight loss best weight loss pills on amazon for men low lectin diet weight loss keto advanced weight loss pills chemist warehouse does a wheat free diet help lose weight low card diet weight loss adios weight loss pills review peanuts weight loss diet resveratrol supplements for weight loss ketogenic diet weight loss stall john hopkins weight loss diet how to plan a vegan weight loss diet susanna reid weight loss pills