/* * Main.

java * * Created on 23 de abril de 2007, 17:06 * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package serie; /** * * @author Invitado */ public class Main { /** Creates a new instance of Main */ public Main() { } /** * @param args the command line arguments */ public static void main(String[] args) { int s1,s2,s,i,n; n=Integer.parseInt(args[0]); s1=0; s2=1; switch(n) { case 1:{ System.out.print("Terminos de la serie:0\t"); System.out.println("\n Con n="+n);break;} case 2:{ System.out.print("Terminos de la serie:0\t1"); System.out.println("\n Con n="+n);break;} default: { System.out.print("Terminos de la serie:\n"+s1+"\t"+s2); i=2; while(i<n) { s=s1+s2; s1=s2; s2=s; i=i+1; System.out.print("\t"+s); }

System.out.println("\n Con n="+n); break; } } } }

Sign up to vote on this title
UsefulNot useful