/*Non Recursive Solution*/ import java.util.Scanner; class Fib { public static void main(String args[ ]) { Scanner input=new Scanner(System.in); int i,a=1,b=1,c=0,t; System.out.println("Enter value of t:"); t=input.nextInt(); System.out.print(a); System.out.print(" "+b); for(i=0;i<t-2;i++) { c=a+b; a=b; b=c; System.out.print(" "+c); } System.out.println(); System.out.print(t+"th value of the series is: "+c); }
JAVA LEARNING:An art and entertainment for those who love it. For Online Assistance and help @email:Learnprogramm@gmail.com
Thursday, 28 April 2011
JAVA PROGRAM TO PRINT NON -RECURSIVE SOLUTIONS
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment