0

help me.. tell the fibonicci code for java

anyone knows?

7th Sep 2016, 1:04 PM
Hisyam Umar
Hisyam Umar - avatar
2 ответов
+ 1
to give a totally recursive definition: http://www.sololearn.com/app/java/playground/clzWIOrso9T7 If you're interested in large fib numbers this is not the best approach to take, I would advise looking into dynamic programming. I have rigged up an example for you here: http://www.sololearn.com/app/java/playground/cGAqfY7KOs9f Note how much faster the dynamic approach is compared to the recursive.
7th Sep 2016, 10:50 PM
Greg Sims
Greg Sims - avatar
0
/* Fibonacci Series */ import java.io.*; class Fibonacci { public static void main(String args[]) { String str; int no,f1,f2,f3; f2=0; f3=1; try{ System.out.print("Enter number to generate it's Fibonacci Series : "); System.out.flush(); BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); str=obj.readLine(); no=Integer.parseInt(str); System.out.print(f3+" "); System.out.flush(); while(no>1) { f1=f2; f2=f3; f3=f1+f2; System.out.print(f3+" "); System.out.flush(); no=no-1; } } catch(Exception e) {} }}
8th Sep 2016, 9:24 AM
kirti chaudhary
kirti chaudhary - avatar