Sáb Sep 04, 2010 2:59 pm
La Serie Fibonacci en consola:
- Código:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
/** --------------------------------------------
* @Author KainRazor
* @WebSite [Tienes que estar registrado y conectado para ver este vínculo]
* @IDE Java Eclipse Helios x64
* @Purpose Fibonacci Serie
* @Requirements Java Virtual Machine (JVM)
* --------------------------------------------
*/
class Fibonacci {
public static BufferedReader lnRead = new BufferedReader(new InputStreamReader (System.in));
public static void main(String args[]) throws IOException {
System.out.println("------------------------------" +
"\n Fibonacci Serie By KainRazor " +
"\n------------------------------" +
"\n\nWrite the length of the serie:");
int iVal = Integer.parseInt(lnRead.readLine());
Start_Lines(iVal);
}
public static void Start_Lines(int iTimes) {
int A=0;
int B=1;
int Aux;
System.out.println("------------------------------" +
"\n"+A);
for (int i = 0; i<iTimes; i++) {
System.out.println(A+B);
Aux=A;
A=A+B;
B=Aux;
}
System.out.println("------------------------------");
}
}